同一 URL 上的多个 SOAP 服务(同一 URL 的不同版本)
我需要支持具有相同 URL 的多个版本的 SOAP 端点,这可能吗? Soap 类是从第三方 wsdl 生成的。
在 web.xml 中,我有:
<servlet>
<servlet-name>soap</servlet-name>
<servlet-class>com.sun.xml.ws.transport.http.servlet.WSSpringServlet</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>soap</servlet-name>
<url-pattern>/soap/*</url-pattern>
</servlet-mapping>
在我的 applicationContext.xml 中,我有以下内容:
<wss:binding url="/soap/StuffService/">
<wss:service>
<ws:service bean="#stuffV1"/>
</wss:service>
</wss:binding>
<bean id="stuffV1" class="package.soap.StuffSoapEndpointV1"/>
我有一个 java 类:
@WebService(
portName = "BasicHttpBinding_IStuffService",
serviceName = "StuffService",
endpointInterface = "package.soap.stuff.IStuffService",
targetNamespace = "http://stuff.example.org/Integration/Service/Outgoing/v1",
wsdlLocation = "/WEB-INF/Integration.Service.Outgoing.v1.IStuff.wsdl")
@ApiOperation(value = "Stuff Service")
public class StuffSoapEndpointV1 implements IStuffService {
是否可以将第二个版本添加到同一网址?大致如下:
<wss:binding url="/soap/StuffService/">
<wss:service>
<ws:service bean="#stuffV1"/>
<ws:service bean="#stuffV2"/>
</wss:service>
</wss:binding>
<bean id="stuffV1" class="package.soap.StuffSoapEndpointV1"/>
<bean id="stuffV2" class="package.soap.StuffSoapEndpointV2"/>
@WebService(
portName = "BasicHttpBinding_IStuffService",
serviceName = "StuffService",
endpointInterface = "package.soap.stuff.IStuffService",
targetNamespace = "http://stuff.example.org/Integration/Service/Outgoing/v2",
wsdlLocation = "/WEB-INF/Integration.Service.Outgoing.v2.IStuff.wsdl")
@ApiOperation(value = "Stuff Service")
public class StuffSoapEndpointV2 implements IStuffService {
那不起作用。不允许使用多个 ws:service 标记,对于具有相同 url 的 wss:service 和 wss:binding 也是如此。另外,我认为 portName 和 serviceName 组合应该是唯一的,但它们需要与不是来自我们的 wsdl 中的相同。
I have a need to support multiple versions of SOAP endpoint with the same URL, is this possible?
Soap classes have been generated from a third party wsdl.
In web.xml I have:
<servlet>
<servlet-name>soap</servlet-name>
<servlet-class>com.sun.xml.ws.transport.http.servlet.WSSpringServlet</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>soap</servlet-name>
<url-pattern>/soap/*</url-pattern>
</servlet-mapping>
In my applicationContext.xml I have the following:
<wss:binding url="/soap/StuffService/">
<wss:service>
<ws:service bean="#stuffV1"/>
</wss:service>
</wss:binding>
<bean id="stuffV1" class="package.soap.StuffSoapEndpointV1"/>
And I have a java class:
@WebService(
portName = "BasicHttpBinding_IStuffService",
serviceName = "StuffService",
endpointInterface = "package.soap.stuff.IStuffService",
targetNamespace = "http://stuff.example.org/Integration/Service/Outgoing/v1",
wsdlLocation = "/WEB-INF/Integration.Service.Outgoing.v1.IStuff.wsdl")
@ApiOperation(value = "Stuff Service")
public class StuffSoapEndpointV1 implements IStuffService {
Is it possible to add a second version to the same url? Something in the lines of:
<wss:binding url="/soap/StuffService/">
<wss:service>
<ws:service bean="#stuffV1"/>
<ws:service bean="#stuffV2"/>
</wss:service>
</wss:binding>
<bean id="stuffV1" class="package.soap.StuffSoapEndpointV1"/>
<bean id="stuffV2" class="package.soap.StuffSoapEndpointV2"/>
@WebService(
portName = "BasicHttpBinding_IStuffService",
serviceName = "StuffService",
endpointInterface = "package.soap.stuff.IStuffService",
targetNamespace = "http://stuff.example.org/Integration/Service/Outgoing/v2",
wsdlLocation = "/WEB-INF/Integration.Service.Outgoing.v2.IStuff.wsdl")
@ApiOperation(value = "Stuff Service")
public class StuffSoapEndpointV2 implements IStuffService {
That doesn't work. Multiple ws:service tags are not allowed, same for wss:service and wss:binding with same url. Also I think that portName and serviceName combo should be unique, but they need to be same as in the wsdl which doesn't come from us.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我为肥皂调用创建了自己的处理程序,类似于 https://github.com/revinate/jaxws-spring/blob/master/jaxws-spring/src/main/java/com/sun/xml/ws/transport/http/servlet/WSSpringServlet.java 具有基本功能。它使用我自己的 WSServletDelegate。
但我添加了 WSServletDelegate,以便它可以读取绑定 url 的多个配置,并用双星号标记。
当请求到达那些带有双星号的 url 时,WSServletDelegate 会将传入的 SOAPAction 标头与 beans 方法 Action 注释值进行比较,如果它们相同,则应使用该 bean。
I created my own handler for soap calls that is similar to https://github.com/revinate/jaxws-spring/blob/master/jaxws-spring/src/main/java/com/sun/xml/ws/transport/http/servlet/WSSpringServlet.java with basic functionality. And it uses my own WSServletDelegate.
But I added the WSServletDelegate so it could read multiple configurations for a binding url, marked with double asterix.
And when a request comes to those urls with double asterix WSServletDelegate compares incoming SOAPAction header to beans methods Action annotation value, and if they are the same then that bean should be used.