Bambus
Bambus

Reputation: 1583

@XmlAttribute(name) invalid name in SoapUI

I am making SOAP web services and when I use

@XmlAttribute(name = "asd:resource")
private String asdResource;

I can not import my wsdl in SoapUI. It shows: Error: The value 'asd:resource' is an invalid name.

And when I use only @XmlAttribute I can import my project but in the response I am receiving it like asdResource without :. That is why I used XmlAttribute(name= "asd:resource")

My question is what can cause this problem and how can i fix it.

Upvotes: 0

Views: 470

Answers (2)

xmlParser
xmlParser

Reputation: 2031

You can try with this class.

@javax.xml.bind.annotation.XmlSchema(namespace = "yournamespace", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED,
xmlns = {
    @XmlNs(prefix="asd", namespaceURI="yournamespace"),
})


package example;

import javax.xml.bind.annotation.XmlNs;

And for

@XmlAttribute(namespace = "yournamespace")
private String resource;

Upvotes: 1

lexicore
lexicore

Reputation: 43671

Apparenty you want to create an attribute with the name resource in a specific namespace. This should be:

@XmlAttribute(name = "resource", namespace="http://...")

namespace should be the namespace associated with the prefix asd.

When marshalling, JAXB will typically "invent" its own namespace prefixes (like ns0 etc.). See the following question if you want to control namespace prefixes:

Is it possible to customize the namespace prefix that JAXB uses when marshalling to a String?

Upvotes: 2

Related Questions