Steve McLeod
Steve McLeod

Reputation: 52488

How can I customise the namespace prefixes in Metro/JavaEE auto-generated WSDL?

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?

Upvotes: 0

Views: 925

Answers (1)

kipz
kipz

Reputation: 365

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">

Upvotes: 1

Related Questions