提供的WSDL文件如下:
<?xml version='1.0' encoding='UTF-8' ?>
<!-- Generated 09/08/09 by Microsoft SOAP Toolkit WSDL File Generator, Version 3.00.1325.0 --> 
<definitions
name='testWeb'
targetNamespace='http://tempuri.org/testWeb/wsdl/'
xmlns:wsdlns='http://tempuri.org/testWeb/wsdl/'
xmlns:typens='http://tempuri.org/testWeb/type/'
xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'
xmlns:stk='http://schemas.microsoft.com/soap-toolkit/wsdl-extension'
xmlns:dime='http://schemas.xmlsoap.org/ws/2002/04/dime/wsdl/'
xmlns:ref='http://schemas.xmlsoap.org/ws/2002/04/reference/'
xmlns:content='http://schemas.xmlsoap.org/ws/2002/04/content-type/'
xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'
xmlns='http://schemas.xmlsoap.org/wsdl/'> <types>
<schema
targetNamespace='http://tempuri.org/testWeb/type/'
xmlns='http://www.w3.org/2001/XMLSchema'
xmlns:SOAP-ENC='http://schemas.xmlsoap.org/soap/encoding/'
xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'
elementFormDefault='qualified'> <import namespace='http://schemas.xmlsoap.org/soap/encoding/'/>
<import namespace='http://schemas.xmlsoap.org/wsdl/'/>
<import namespace='http://schemas.xmlsoap.org/ws/2002/04/reference/'/>
<import namespace='http://schemas.xmlsoap.org/ws/2002/04/content-type/'/> </schema>
</types> <message name='testInterface.Add'>
<part name='a' type='xsd:int'/>
<part name='b' type='xsd:int'/>
</message> <message name='testInterface.AddResponse'>
<part name='retVal' type='xsd:int'/>
</message> <message name='testInterface.AddString'>
<part name='a' type='xsd:int'/>
<part name='b' type='xsd:int'/>
</message> <message name='testInterface.AddStringResponse'>
<part name='retString' type='xsd:string'/>
</message> <portType name='testInterfaceSoapPort'> <operation name='Add' parameterOrder='a b retVal'>
<input message='wsdlns:testInterface.Add'/>
<output message='wsdlns:testInterface.AddResponse'/>
</operation> <operation name='AddString' parameterOrder='a b retString'>
<input message='wsdlns:testInterface.AddString'/>
<output message='wsdlns:testInterface.AddStringResponse'/>
</operation> </portType> <binding name='testInterfaceSoapBinding' type='wsdlns:testInterfaceSoapPort' > <stk:binding preferredEncoding='UTF-8'/>
<soap:binding style='rpc' transport='http://schemas.xmlsoap.org/soap/http'/> <operation name='Add'>
<soap:operation soapAction='http://tempuri.org/testWeb/action/testInterface.Add'/>
<input>
<soap:body
use='encoded'
namespace='http://tempuri.org/testWeb/message/'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'
parts='a b'/>
</input>
<output>
<soap:body
use='encoded'
namespace='http://tempuri.org/testWeb/message/'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'
parts='retVal'/>
</output>
</operation> <operation name='AddString'>
<soap:operation soapAction='http://tempuri.org/testWeb/action/testInterface.AddString'/>
<input>
<soap:body
use='encoded'
namespace='http://tempuri.org/testWeb/message/'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'
parts='a b'/>
</input>
<output>
<soap:body
use='encoded'
namespace='http://tempuri.org/testWeb/message/'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'
parts='retString'/>
</output>
</operation> </binding> <service name='testWeb' >
<port name='testInterfaceSoapPort' binding='wsdlns:testInterfaceSoapBinding' >
<soap:address location='http://127.0.0.1/MyWeb/testWeb.WSDL'/>
</port>
</service></definitions>现在要调用其中的Add方法,代码如下:
::CoInitialize(NULL);
m_Connector.CreateInstance(__uuidof(HttpConnector));
m_Connector->PutProperty("EndPointURL","http://127.0.0.1/MyWeb/testWeb.WSDL");
HRESULT hr = m_Connector->Connect();
m_Connector->PutProperty("SoapAction","http://tempuri.org/testWeb/action/testInterface.Add");
m_Connector->BeginMessage();

m_Serializer.CreateInstance(__uuidof(SoapSerializer));
m_Serializer->Init(_variant_t((IUnknown*)m_Connector->InputStream));

m_Serializer->startEnvelope("","","");
m_Serializer->startBody("");
m_Serializer->startElement("Add","http://tempuri.org/testWeb/message/","",""); m_Serializer->startElement("a","","","");
m_Serializer->writeString("5");
m_Serializer->endElement(); m_Serializer->startElement("b","","","");
m_Serializer->writeString("7");
m_Serializer->endElement(); m_Serializer->endElement();
m_Serializer->endBody();
m_Serializer->endEnvelope(); m_Connector->EndMessage();
//读响应
m_Reader.CreateInstance(__uuidof(SoapReader)); 
m_Reader->Load(_variant_t((IUnknown*)m_Connector->OutputStream), ""); 
char resbuf[1024];
sprintf(resbuf,"Answer: %s\n", (const char *)m_Reader->RPCResult->text); 
不知道哪儿有错误,在m_Connector->EndMessage();出现异常退出了,有熟悉SOAP和MSSOAP的讲讲,谢谢!