Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
可以在SpringWS-webservice中重命名th响应名称空间前缀吗?_Spring_Web Services_Jaxb_Xml Namespaces_Spring Ws - Fatal编程技术网

可以在SpringWS-webservice中重命名th响应名称空间前缀吗?

可以在SpringWS-webservice中重命名th响应名称空间前缀吗?,spring,web-services,jaxb,xml-namespaces,spring-ws,Spring,Web Services,Jaxb,Xml Namespaces,Spring Ws,我已经基于上的示例构建了一个SpringWS-webservice。响应包含前缀为“ns2”的我的命名空间 Soap响应 <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"> <SOAP-ENV:Header/> <SOAP-ENV:Body> <ns2:mitteilungResponse xmlns:ns2="http://

我已经基于上的示例构建了一个SpringWS-webservice。响应包含前缀为“ns2”的我的命名空间

Soap响应

<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”?怎么用?有人吗?

好的,我找到了解决办法。这很简单。。。只需将其添加到包info.java中的@XmlSchema注释中,如下所示:

@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;

好的,我找到了解决办法。这很简单。。。只需将其添加到包info.java中的@XmlSchema注释中,如下所示:

@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;