问题
I've build a Spring WS webservice based on the example at http://spring.io/guides/gs/producing-web-service/. The response contains my namespace with the prefix "ns2".
xmlns:ns2="http://www.mycompany.com/somewhere"
Soap-Response
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<ns2:mitteilungResponse xmlns:ns2="http://www.mycompany.com/somewhere">
<ns2:responseContent>
<ns2:message>Hello World!</ns2:message>
</ns2:responseContent>
</ns2:mitteilungResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Is it possible to rename that prefix to "myprefix"? How? Anybody?
回答1:
OK, i found the solution. It's pretty easy... Simply add it to the @XmlSchema-Annotation in the package-info.java as follows:
@XmlSchema(
xmlns = {
@XmlNs(prefix = "myprefix", namespaceURI="http://www.mycompany.com/foobar")
},
namespace = "http://www.mycompany.com/somewhere",
elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED
)
package com.mycompany.project;
来源:https://stackoverflow.com/questions/28538896/is-it-possible-to-rename-th-response-namespace-prefix-in-a-spring-ws-webservice