仅配置了java SOAP12,但出现错误“传入的SOAP消息协议版本为1.1”
我已经使用JAX-WS在WebSphere(7)中配置了WebService。在上周,所有内容都进行了测试,但今天,在清理和刷新之后,我发现一个错误:
Caused by: javax.xml.ws.soap.SOAPFaultException: Incoming SOAP message protocol is version 1.1, but endpoint is configured for SOAP 1.2. This is not supported. at org.apache.axis2.jaxws.marshaller.impl.alt.MethodMarshallerUtils.createSystemException(MethodMarshallerUtils.java:1310) at org.apache.axis2.jaxws.marshaller.impl.alt.MethodMarshallerUtils.demarshalFaultResponse(MethodMarshallerUtils.java:1036) at org.apache.axis2.jaxws.marshaller.impl.alt.DocLitBareMethodMarshaller.demarshalFaultResponse(DocLitBareMethodMarshaller.java:412) at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.getFaultResponse(JAXWSProxyHandler.java:529) at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.createResponse(JAXWSProxyHandler.java:470) at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invokeSEIMethod(JAXWSProxyHandler.java:377) at org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler.invoke(JAXWSProxyHandler.java:185)
最令人惊讶的是,SOAP1.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 楼答案
这是客户端的问题,尤其是JAX-WS生成的客户端存根构造函数的问题
我通过调用三参数构造函数解决了这个问题:
而不是基于strage生成的代码输出的无参数构造函数: