0

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.

RubioRic
  • 2,442
  • 4
  • 28
  • 35
Bambus
  • 1,493
  • 1
  • 15
  • 32

2 Answers2

2

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?

lexicore
  • 42,748
  • 17
  • 132
  • 221
1

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;
xmlParser
  • 1,903
  • 4
  • 19
  • 48