C++ 使用soap调用webservice问题
有一个webservice,我需要访问此接口,下面是它的wsdl:
- <wsdl:operation name="retrieveUserUsageQuota" parameterOrder="subId">
<wsdl:input message="impl:retrieveUserUsageQuotaRequest" name="retrieveUserUsageQuotaRequest" />
<wsdl:output message="impl:retrieveUserUsageQuotaResponse" name="retrieveUserUsageQuotaResponse" />
</wsdl:operation>
我从soap help文档中找到了一个c++的例子:
#include "stdafx.h"
#include < stdio.h>
#import "msxml3.dll"
using namespace MSXML2;
#import "C:\Program Files\Common Files\MSSoap\Binaries\mssoap1.dll" \
exclude("IStream", "ISequentialStream", "_LARGE_INTEGER", \
"_ULARGE_INTEGER", "tagSTATSTG", "_FILETIME")
using namespace MSSOAPLib;
void Add()
{
ISoapSerializerPtr Serializer;
ISoapReaderPtr Reader;
ISoapConnectorPtr Connector;
// Connect to the service
Connector.CreateInstance(__uuidof(HttpConnector));
Connector->Property["EndPointURL"] = "http://localhost/DocSample2/DocSample2.asp";
Connector->Connect();
// Begin message
Connector->Property["SoapAction"] = "uri:AddNumbers";
Connector->BeginMessage();
// Create the SoapSerializer
Serializer.CreateInstance(__uuidof(SoapSerializer));
// Connect the serializer to the input stream of the connector
Serializer->Init(_variant_t((IUnknown*)Connector->InputStream));
// Build the SOAP Message
Serializer->startEnvelope("","","");
Serializer->startBody("");
Serializer->startElement("Add","uri:Calc","","m");
Serializer->startElement("A","","","");
Serializer->writeString("5");
Serializer->endElement();
Serializer->startElement("B","","","");
Serializer->writeString("10");
Serializer->endElement();
Serializer->endElement();
Serializer->endBody();
Serializer->endEnvelope();
// Send the message to the web service
Connector->EndMessage();
// Let us read the response
Reader.CreateInstance(__uuidof(SoapReader));
// Connect the reader to the output stream of the connector
Reader->Load(_variant_t((IUnknown*)Connector->OutputStream), "");
// Display the result
printf("Answer: %s\n", (const char*)Reader->RPCResult->text);
}
int main()
{
CoInitialize(NULL);
Add();
CoUninitialize();
return 0;
}
但是,不清楚soap以及wsdl等等规范,希望那位老大可以帮我改好上面的访问例子。实在是急事,没时间详细看soap和wsdl,等这个demo做出来我再细细研究,谢谢各位了。
或者帮我介绍一下,使用soap访问这个webservice时候需要如何写message...