是否可以在Spring WS Web服务中重命名响应命名空间前缀? [英] Is it possible to rename th response namespace-prefix in a Spring WS webservice?

查看:403
本文介绍了是否可以在Spring WS Web服务中重命名响应命名空间前缀?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我基于 Spring WS webservice nofollow的> http://spring.io/guides/gs/producing-web-service/ 。响应包含我的命名空间,前缀为ns2。

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-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?怎么样?任何人?

Is it possible to rename that prefix to "myprefix"? How? Anybody?

推荐答案

好的,我找到了解决方案。这很简单......只需将它添加到 package-info.java 中的@ XmlSchema-Annotation,如下所示:

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;

这篇关于是否可以在Spring WS Web服务中重命名响应命名空间前缀?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆