是否可以在 Spring WS 网络服务中重命名响应命名空间前缀?
Is it possible to rename th response namespace-prefix in a Spring WS webservice?
我已经根据 http://spring.io/guides/gs/producing-web-service/ 中的示例构建了 Spring WS 网络服务。响应包含前缀为 "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"?如何?有人吗?
好的,我找到了解决方案。很简单...只需将其添加到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;
我已经根据 http://spring.io/guides/gs/producing-web-service/ 中的示例构建了 Spring WS 网络服务。响应包含前缀为 "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"?如何?有人吗?
好的,我找到了解决方案。很简单...只需将其添加到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;