发送SOAP请求给WSDL, 超级难题!!!高手请进。
WSDL运行良好,定义如下:
<?xml version="1.0" ?>
- <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://schemas.ABCD.com/default" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:inst="http://schemas.ABCD.com/APM/instance/1.0" name="3rdParties" targetNamespace="http://schemas.ABCD.com/default">
- <wsdl:types>
- <xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:tns1="http://schemas.ABCD.com/default" xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://schemas.ABCD.com/default">
<xsd:element xmlns:xs="http://www.w3.org/2001/XMLSchema" name="TheReference" type="xs:string" />
- <xsd:element name="GetHandlingResponse">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element name="data">
- <xsd:complexType>
- <xsd:sequence>
<xsd:element name="instance_id" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element xmlns:xs="http://www.w3.org/2001/XMLSchema" name="Location" type="xs:string" />
<xsd:element xmlns:xs="http://www.w3.org/2001/XMLSchema" name="Reserve" type="xs:string" />
- <xsd:element name="GetHandling">
- <xsd:complexType>
- <xsd:sequence>
<xsd:element ref="tns1:TheReference" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
- <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://schemas.ABCD.com/APM/instance/1.0">
- <xsd:element name="APM">
- <xsd:complexType>
- <xsd:sequence>
<xsd:element name="instance_id" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
- <wsdl:message name="GetHandlingInput">
<wsdl:part name="body" element="tns:GetHandling" />
</wsdl:message>
- <wsdl:message name="GetHandlingOutput">
<wsdl:part name="body" element="tns:GetHandlingResponse" />
</wsdl:message>
- <wsdl:message name="HeaderOutput">
<wsdl:part name="MyHeader" element="inst:APM" />
</wsdl:message>
- <wsdl:portType name="GetMessages">
- <wsdl:operation name="GetHandling">
<wsdl:input message="tns:GetHandlingInput" />
<wsdl:output message="tns:GetHandlingOutput" />
</wsdl:operation>
</wsdl:portType>
- <wsdl:binding name="GetMessages" type="tns:GetMessages">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="GetHandling">
<soap:operation soapAction="" style="document" />
- <wsdl:input>
<soap:body use="literal" />
</wsdl:input>
- <wsdl:output>
<soap:body use="literal" />
<soap:header message="tns:HeaderOutput" part="MyHeader" use="literal" />
<soap:header message="tns:HeaderOutput" part="MyHeader" use="literal" />
<soap:header message="tns:HeaderOutput" part="MyHeader" use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:service name="GetMessagesService">
- <wsdl:port name="GetMessagesPort" binding="tns:GetMessages">
<soap:address location="https://my.ABCD.com/ABCD" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
现在我想给上面的WSDL发送一个SOAP请求,然后得到结果。
发送请求的XML:
<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP:Body>
<GetHandling xmlns="http://schemas.ABCD.com/default">
<TheReference>123456</TheReference>
</GetHandling>
</SOAP:Body>
</SOAP:Envelope>
我想得到的结果(返回的XML)是:
<data>
<GetHandlingResponse xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://schemas.ABCD.com/default">
<data xmlns="http://schemas.ABCD.com/APM/execution/1.0">
<instance_id>112233445566</instance_id>
</data>
</GetHandlingResponse>
</data>
请问用c#怎样写啊?