在同一URL上使用SOAP11和SOAP12绑定部署Metro Web Service?

时间:2013-02-25 09:46:58

标签: java jax-ws java-metro-framework

我有一个遗留的Web服务,我正试图从Axis2迁移到Glassfish / Metro,我偶然发现了一个问题:

有一个WSDL文件,其中包含一个wsdl:service元素,其中包含对两个wsdl:port元素的引用,一个用于SOAP11,另一个用于SOAP12。

特别是,WSDL的那部分看起来像这样:

<wsdl:service name="WebServiceInterface">
    <wsdl:port name="WebServiceSOAP11port"
        binding="ns:WebServiceSOAP11Binding">
        <soap:address
            location="http://localhost:8081/axis2/services/WebService" />
    </wsdl:port>
    <wsdl:port name="WebServiceSOAP12port"
        binding="ns:WebServiceSOAP12Binding">
        <soap12:address
            location="http://localhost:8081/axis2/services/WebService" />
    </wsdl:port>
</wsdl:service>

尝试设置类作为端点,我有以下内容:

@WebService(name = "WebServicePortType", targetNamespace = "http://abc/", portName="WebServiceSOAP11port", endpointInterface = "abc.WebServicePortType", serviceName = "WebServiceInterface", wsdlLocation = "WebService.wsdl")
@BindingType(SOAPBinding.SOAP11HTTP_BINDING)
public class WebServiceSoap11Impl extends WebServiceBase implements WebServicePortType {
    // Superclass handles actual method calls - this is just here for binding to Soap 1.1.
}
@WebService(name = "WebServicePortType", targetNamespace = "http://abc/", portName="WebServiceSOAP12port", endpointInterface = "abc.WebServicePortType", serviceName = "WebServiceInterface", wsdlLocation = "WebService.wsdl")
@BindingType(SOAPBinding.SOAP12HTTP_BINDING)
public class WebServiceSoap12Impl extends WebServiceBase implements WebServicePortType  {
    // Superclass handles actual method calls - this is just here for binding to Soap 1.2.
}

现在,这适用于SOAP11绑定,但如果我尝试通过soapUI使用SOAP12绑定,我会收到以下错误:

[#|2013-02-25T22:31:25.299+1300|SEVERE|glassfish3.1.2|com.sun.xml.ws.transport.http.HttpAdapter|_ThreadID=227;_ThreadName=http-thread-pool-8782(5);|Unsupported Content-Type: application/soap+xml;charset=UTF-8;action="urn:heartBeat" Supported ones are: [text/xml]
com.sun.xml.ws.server.UnsupportedMediaException: Unsupported Content-Type: application/soap+xml;charset=UTF-8;action="urn:heartBeat" Supported ones are: [text/xml]
    at com.sun.xml.ws.encoding.StreamSOAPCodec.decode(StreamSOAPCodec.java:315)
    at com.sun.xml.ws.encoding.StreamSOAPCodec.decode(StreamSOAPCodec.java:149)
    at com.sun.xml.ws.encoding.SOAPBindingCodec.decode(SOAPBindingCodec.java:361)
    at com.sun.xml.ws.transport.http.HttpAdapter.decodePacket(HttpAdapter.java:343)
    at com.sun.xml.ws.transport.http.HttpAdapter.access$400(HttpAdapter.java:99)
    at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:623)
    at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:263)
    at com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:163)
    at org.glassfish.webservices.JAXWSServlet.doPost(JAXWSServlet.java:145)

显然,Content-Type对于SOAP12是正确的,但由于某种原因,Metro没有意识到我有两个类用于同一个端点 - 1个绑定到SOAP11,1个绑定到SOAP12。 Axis2似乎能够处理该用例。 Metro支持这个吗?或者我必须为SOAP11和12提供单独的端点吗?或者我应该放弃对其中一个的支持?

我正在使用Java 1.7.0_4

在Ubuntu 10.04上运行Glassfish 3.1.2.2

0 个答案:

没有答案