1

For my web service, I have defined the request and response XML structures in java classes in a package, I use @XmlElement annotations.

I have also a package-info.java file defining @XmlSchema for the whole package and also defining what the prefix for the XML elements should be:

@XmlSchema(namespace = XmlNamespace.MY_SERVICE,
  xmlns = { @XmlNs(namespaceURI = XmlNamespace.MY_SERVICE, prefix = "ser")},
  elementFormDefault = XmlNsForm.QUALIFIED)

The problem is: I use 2 namespaces for the request, so I want some of the XML elements with prefix <ser:element1> and others with <req:element2>. The generated wsdl and request already gave me 2 different prefixes, but the second prefix is not the one I want – “req”.

How can I achieve this? I tried with

@XmlSchema(namespace = XmlNamespace.MY_SERVICE,
  xmlns = { @XmlNs(namespaceURI = XmlNamespace.MY_SERVICE, prefix = "ser"),
        @XmlNs(namespaceURI = XmlNamespace.MY_SERVICE_XSD, prefix = "per2")},
  elementFormDefault = XmlNsForm.QUALIFIED)

but it’s not working.

4

0 回答 0