views:

251

answers:

1

I'm using Java 6 + JavaEE + Tomcat 6 + Metro for SOAP web services. In the response, the namespace prefixes are ns2, ns3, ns4, and so on. I'd like to be able to instruct the web services stack to use custom names instead.

How do I do this?

+1  A: 

Use the @XmlSchema annotation (assuming you are using JAXB2.x)

@XmlSchema (
  xmlns = { 
    @XmlNs(prefix = "so", 
               namespaceURI="http://stackoverflow.com/questions/358991")
  )
)

Would result in:

<schema
    xmlns:so="http://stackoverflow.com/questions/358991"
    targetNamespace="http://stackoverflow.com/questions/358991"&gt;
kipz