【问题标题】:Is it possible to rename th response namespace-prefix in a Spring WS webservice?是否可以在 Spring WS Web 服务中重命名响应命名空间前缀?
【发布时间】:2015-02-16 10:06:09
【问题描述】:

我已经基于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”?如何?有人吗?

【问题讨论】:

    标签: spring web-services jaxb xml-namespaces spring-ws


    【解决方案1】:

    好的,我找到了解决方案。这很简单...只需将其添加到 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;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-10-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多