.net framework(<4.8.1)引入Apache CXF WebService的过程,总会观察如下异常:
org.apache.cxf.interceptor.Fault: No binding operation info while invoking unknown method with params unknown.
和
org.apache.cxf.binding.soap.SoapFault: MustUnderstand headers: [{http://www.w3.org/2005/08/addressing}Action, {http://www.w3.org/2005/08/addressing}To] are not understood.
以上异常,并不影响WebService的使用。在新版.net引入Apache CXF WebService并没有发现同样问题。
以下是通过WireShark观察到.net framework(<4.8.1)引入Apache CXF WebService的网络过程:
- POST http://localhost:8080/cxf/greet?wsdl
Body:
<s:Envelope
xmlns:s="http://www.w3.org/2003/05/soap-envelope"
xmlns:a="http://www.w3.org/2005/08/addressing">
<s:Header>
<a:Action
s:mustUnderstand="1">
http://schemas.xmlsoap.org/ws/2004/09/transfer/Get
</a:Action>
<a:MessageID>
urn:uuid:8f0e9a4f-a680-4851-a103-4afd305a6a40
</a:MessageID>
<a:ReplyTo>
<a:Address>
http://www.w3.org/2005/08/addressing/anonymous
</a:Address>
</a:ReplyTo>
<a:To
s:mustUnderstand="1">
http://localhost:8080/cxf/greet?wsdl
</a:To>
</s:Header>
<s:Body/>
</s:Envelope>
- GET http://localhost:8080/cxf/greet?wsdl/$metadata
引发服务端异常:
org.apache.cxf.interceptor.Fault: No binding operation info while invoking unknown method with params unknown.
Response:
<soap:Envelope
xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Body>
<soap:Fault>
<soap:Code>
<soap:Value>soap:Receiver</soap:Value>
</soap:Code>
<soap:Reason>
<soap:Text xml:lang="en">No binding operation info while invoking unknown method with params unknown.</soap:Text>
</soap:Reason>
</soap:Fault>
</soap:Body>
</soap:Envelope>
- POST http://localhost:8080/cxf/greet?wsdl/mex
引发服务端异常:
org.apache.cxf.binding.soap.SoapFault: MustUnderstand headers: [{http://www.w3.org/2005/08/addressing}Action, {http://www.w3.org/2005/08/addressing}To] are not understood.
Body:
<s:Envelope
xmlns:s="http://www.w3.org/2003/05/soap-envelope"
xmlns:a="http://www.w3.org/2005/08/addressing">
<s:Header>
<a:Action
s:mustUnderstand="1">
http://schemas.xmlsoap.org/ws/2004/09/transfer/Get
</a:Action>
<a:MessageID>
urn:uuid:b7eb652a-e4c1-4037-8acf-220f1b25fe31
</a:MessageID>
<a:ReplyTo>
<a:Address>
http://www.w3.org/2005/08/addressing/anonymous
</a:Address>
</a:ReplyTo>
<a:To
s:mustUnderstand="1">
http://localhost:8080/cxf/greet?wsdl/mex
</a:To>
</s:Header>
<s:Body/>
</s:Envelope>
Response:
<soap:Envelope
xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Body>
<soap:Fault>
<soap:Code>
<soap:Value>soap:MustUnderstand</soap:Value>
</soap:Code>
<soap:Reason>
<soap:Text xml:lang="en">MustUnderstand headers: [{http://www.w3.org/2005/08/addressing}Action, {http://www.w3.org/2005/08/addressing}To] are not understood.</soap:Text>
</soap:Reason>
</soap:Fault>
</soap:Body>
</soap:Envelope>
- GET http://localhost:8080/cxf/greet?wsdl
Response:
<?xml
<wsdl:definitions
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="http://webservice.webservcietest.practice.ibc.com/"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:ns1="http://schemas.xmlsoap.org/soap/http"
name="GreetImplService"
targetNamespace="http://webservice.webservcietest.practice.ibc.com/">
<wsdl:types>
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://webservice.webservcietest.practice.ibc.com/"
elementFormDefault="unqualified"
targetNamespace="http://webservice.webservcietest.practice.ibc.com/"
version="1.0">
<xs:element
name="sayHello"
type="tns:sayHello"/>
<xs:element
name="sayHello2"
type="tns:sayHello2"/>
<xs:element
name="sayHello2Response"
type="tns:sayHello2Response"/>
<xs:element
name="sayHelloResponse"
type="tns:sayHelloResponse"/>
<xs:complexType
name="sayHello">
<xs:sequence>
<xs:element
minOccurs="0"
name="name"
type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType
name="sayHelloResponse">
<xs:sequence>
<xs:element
minOccurs="0"
name="return"
type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType
name="sayHello2">
<xs:sequence>
<xs:element
minOccurs="0"
name="name"
type="xs:string"/>
<xs:element
minOccurs="0"
name="company"
type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType
name="sayHello2Response">
<xs:sequence>
<xs:element
minOccurs="0"
name="return"
type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>
<wsdl:message
name="sayHello">
<wsdl:part
element="tns:sayHello"
name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message
name="sayHello2Response">
<wsdl:part
element="tns:sayHello2Response"
name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message
name="sayHelloResponse">
<wsdl:part
element="tns:sayHelloResponse"
name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message
name="sayHello2">
<wsdl:part
element="tns:sayHello2"
name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:portType
name="Greet">
<wsdl:operation
name="sayHello">
<wsdl:input
message="tns:sayHello"
name="sayHello">
</wsdl:input>
<wsdl:output
message="tns:sayHelloResponse"
name="sayHelloResponse">
</wsdl:output>
</wsdl:operation>
<wsdl:operation
name="sayHello2">
<wsdl:input
message="tns:sayHello2"
name="sayHello2">
</wsdl:input>
<wsdl:output
message="tns:sayHello2Response"
name="sayHello2Response">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding
name="GreetImplServiceSoapBinding"
type="tns:Greet">
<soap12:binding
style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation
name="sayHello">
<soap12:operation
soapAction=""
style="document"/>
<wsdl:input
name="sayHello">
<soap12:body
use="literal"/>
</wsdl:input>
<wsdl:output
name="sayHelloResponse">
<soap12:body
use="literal"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation
name="sayHello2">
<soap12:operation
soapAction=""
style="document"/>
<wsdl:input
name="sayHello2">
<soap12:body
use="literal"/>
</wsdl:input>
<wsdl:output
name="sayHello2Response">
<soap12:body
use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service
name="GreetImplService">
<wsdl:port
binding="tns:GreetImplServiceSoapBinding"
name="GreetImplPort">
<soap12:address
location="http://localhost:8080/cxf/greet"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
结论:网络调用2(wsdl/$metadata)和网络调用3(wsdl/mex)不被Apache CXF支持,从而引发服务端出现异常消息,但不会引起服务端失效,服务也可以引入并正常使用。