我根据http://spring.io/guides/gs/producing-web-service/的示例构建了一个 Spring WS webservice 。响应包含带有前缀“ns2”的命名空间。
xmlns:ns2="http://www.mycompany.com/somewhere"
皂响应
<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>
是否可以将该前缀重命名为“myprefix”?怎么样?任何人
答案 0 :(得分:8)
好的,我找到了解决方案。这很简单......只需将其添加到 package-info.java 中的@ XmlSchema-Annotation,如下所示:
@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;