<wsdl:types />
<wsdl:message name="AddSoapIn">
<wsdl:part name="a" type="s:int" />
<wsdl:part name="b" type="s:int" />
</wsdl:message>
<wsdl:message name="AddSoapOut">
<wsdl:part name="AddResult" type="s:int" />
</wsdl:message>
<wsdl:portType name="MathServiceSoap">
<wsdl:operation name="Add">
<wsdl:input message="tns:AddSoapIn" />
<wsdl:output message="tns:AddSoapOut" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="MathServiceSoap" type="tns:MathServiceSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
<wsdl:operation name="Add">
<soap:operation soapAction="http://idior.cnblogs.com/Math/Add" style="rpc" />
<wsdl:input>
<soap:body use="encoded" namespace="http://tempuri.org/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</wsdl:input>
<wsdl:output>
<soap:body use="encoded" namespace="http://tempuri.org/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:message name="AddSoapIn">
<wsdl:part name="a" type="s:int" />
<wsdl:part name="b" type="s:int" />
</wsdl:message>
<wsdl:message name="AddSoapOut">
<wsdl:part name="AddResult" type="s:int" />
</wsdl:message>
<wsdl:portType name="MathServiceSoap">
<wsdl:operation name="Add">
<wsdl:input message="tns:AddSoapIn" />
<wsdl:output message="tns:AddSoapOut" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="MathServiceSoap" type="tns:MathServiceSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
<wsdl:operation name="Add">
<soap:operation soapAction="http://idior.cnblogs.com/Math/Add" style="rpc" />
<wsdl:input>
<soap:body use="encoded" namespace="http://tempuri.org/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</wsdl:input>
<wsdl:output>
<soap:body use="encoded" namespace="http://tempuri.org/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
以上是一段wsdl的片断,其中主要定义了一个Add方法。针对粗体字部分,我们得到以下使用该webservice的soap请求。
POST /WebService1/Service1.asmx HTTP/1.1
Host: localhost
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://idior.cnblogs.com/Math/Add"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://tempuri.org/" xmlns:types="http://tempuri.org/encodedTypes" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<tns:Add>
<a xsi:type="xsd:int">int</a>
<b xsi:type="xsd:int">int</b>
</tns:Add>
</soap:Body>
</soap:Envelope>
Host: localhost
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://idior.cnblogs.com/Math/Add"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://tempuri.org/" xmlns:types="http://tempuri.org/encodedTypes" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<tns:Add>
<a xsi:type="xsd:int">int</a>
<b xsi:type="xsd:int">int</b>
</tns:Add>
</soap:Body>
</soap:Envelope>
可以看出在WSDL中定义好的SoapAction被放在了Http的请求头中, 为了调用Add这个WebService中的方法,SOAP包中粗体字部分发出的请求恰恰对应了WSDL中定义的operation的name---Add.
那么对于下面的WSDL文件,我们又该发出怎样的SOAP请求呢?
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
<s:element name="Add">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="a" type="s:int" />
<s:element minOccurs="1" maxOccurs="1" name="b" type="s:int" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="AddReponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="AddOperationResult" type="s:int" />
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
</wsdl:types>
<wsdl:message name="AddOperationSoapIn">
<wsdl:part name="parameters" element="tns:Add" />
</wsdl:message>
<wsdl:message name="AddOperationSoapOut">
<wsdl:part name="parameters" element="tns:AddReponse" />
</wsdl:message>
<wsdl:portType name="MathServiceSoap">
<wsdl:operation name="AddOperation">
<wsdl:input message="tns:AddOperationSoapIn" />
<wsdl:output message="tns:AddOperationSoapOut" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="MathServiceSoap" type="tns:MathServiceSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
<wsdl:operation name="AddOperation">
<soap:operation soapAction="http://idior.cnblogs.com/Math/Add" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/">
<s:element name="Add">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="a" type="s:int" />
<s:element minOccurs="1" maxOccurs="1" name="b" type="s:int" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="AddReponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="AddOperationResult" type="s:int" />
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
</wsdl:types>
<wsdl:message name="AddOperationSoapIn">
<wsdl:part name="parameters" element="tns:Add" />
</wsdl:message>
<wsdl:message name="AddOperationSoapOut">
<wsdl:part name="parameters" element="tns:AddReponse" />
</wsdl:message>
<wsdl:portType name="MathServiceSoap">
<wsdl:operation name="AddOperation">
<wsdl:input message="tns:AddOperationSoapIn" />
<wsdl:output message="tns:AddOperationSoapOut" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="MathServiceSoap" type="tns:MathServiceSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
<wsdl:operation name="AddOperation">
<soap:operation soapAction="http://idior.cnblogs.com/Math/Add" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
现在为了调用AddOperation(注意 Add改成AddOperation了)方法,你认为Soap Body中对应的那个元素名???是什么呢?
POST /WebService1/Service1.asmx HTTP/1.1
Host: localhost
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://idior.cnblogs.com/Math/Add"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<??? xmlns="http://tempuri.org/">
<a>int</a>
<b>int</b>
</???>
</soap:Body>
</soap:Envelope>
Host: localhost
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://idior.cnblogs.com/Math/Add"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<??? xmlns="http://tempuri.org/">
<a>int</a>
<b>int</b>
</???>
</soap:Body>
</soap:Envelope>
http://www.cnblogs.com/ryhan/archive/2011/05/03/2035633.html