仅配置了SOAP12,但出现错误“Incoming SOAP message protocol is version 1.1”

时间:2013-10-14 06:47:54

标签: java web-services soap websphere jax-ws

我使用JAX-WS在WebSphere(7)中配置了WebService。在上周,一切都经过测试,但今天,在清理和刷新之后,我收到了一个错误:

  

引起:javax.xml.ws.soap.SOAPFaultException:传入的SOAP消息   protocol是版本1.1,但端点是为SOAP 1.2配置的。   这不受支持。在   org.apache.axis2.jaxws.marshaller.impl.alt.MethodMarshallerUtils.createSystemException(MethodMarshallerUtils.java:1310)     在   org.apache.axis2.jaxws.marshaller.impl.alt.MethodMarshallerUtils.demarshalFaultResponse(MethodMarshallerUtils.java:1036)     在   org.apache.axis2.jaxws.marshaller.impl.alt.DocLitBareMethodMarshaller.demarshalFaultResponse(DocLitBareMethodMarshaller.java:412)     在   org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.getFaultResponse(JAXWSProxyHandler.java:529)     在   org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.createResponse(JAXWSProxyHandler.java:470)     在   org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invokeSEIMethod(JAXWSProxyHandler.java:377)     在   org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invoke(JAXWSProxyHandler.java:185)

最令人惊讶的是,SOAP 1.1从未配置过。从一开始,仅使用SOAP 1.2。这是我的WSDL的摘要:

<wsdl:definitions name="ucmdbservice"
    targetNamespace="http://service.my/v3" 
    xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" 
    xmlns:tns="http://service.my/v3"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">

    <wsdl:binding name="binding_soap12_v3" type="tns:v3">

        <soap12:binding style="document"
            transport="http://schemas.xmlsoap.org/soap/http" />
        <wsdl:operation name="getResult">
            <soap12:operation
                soapAction="http://service.my/v3/getResult" />
            <wsdl:input>
                <soap12:body use="literal" />
            </wsdl:input>
            <wsdl:output>
                <soap12:body use="literal" />
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>

    <wsdl:service name="service_v3">
        <wsdl:port name="port_soap12_v3" binding="tns:binding_soap12_v3">
            <soap12:address location="http://host.my/v3"/>
        </wsdl:port>
    </wsdl:service>

</wsdl:definitions>

这是Servlet类的标题注释:

@javax.jws.WebService(wsdlLocation = "wsdl/myservice_v3.wsdl", 
       endpointInterface = "my.service.V3", 
       targetNamespace = "http://service.my/v3", 
       serviceName = "myservice_v3", 
       portName = "port_soap12_v3")
@javax.xml.ws.BindingType(value = javax.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING)

和客户端的注释,从相同的WSDL生成:

@WebServiceClient(name = "myservice_v3", 
    targetNamespace = "http://service.my/v3", 
    wsdlLocation = "../../wsdl/myservice_v3.wsdl")

一切都已经奏效了。它在IBM RAD 8.0中进行了测试,所以我想一些RAD问题,而不是WebSphere问题或JAX-WS问题,但可能是这样,我没有看到定义中明显缺少的东西。

注意:出于机密性原因,服务名称和命名空间会发生变化,因此不要寻找命名空间不匹配:)

1 个答案:

答案 0 :(得分:0)

这是客户端的问题,特别是由JAX-WS生成的客户端存根构造函数。

我通过调用3参数构造函数解决了这个问题:

MyServiceV3 service = new MyServiceV3(
  MyService.class.getResource("/wsdl/myservice_v3.wsdl",
  new QName("http://service.my/v3"), "myservice_v3");

而不是无参数构造函数,它基于该生成代码的输出:

  baseUrl = MyServiceV3 .class.getResource(".");
  url = new URL(baseUrl, "../../wsdl/myservice_v3.wsdl");