于加载XML文件或字符串
将回应信息加载到SoapReader对象之后,就可以用它的RPCResult属性来获取结果。不过,But RPCResult并不直接返回结果,它返回<Body>的第一个实体元素,然后用text属性读取该元素属性值:
Reader->RPCResult->text
三、举例说明一个简单的SOAP客户端应用:
本文示例用www.xmethods.net做服务器。这个服务器指向Yahoo在线信息。
可以在http://www.xmethods.net/ve2/ViewListing.po?serviceid=156找到有关细节。
下面的代码中要输入一个参数,即Yahoo的用户ID。返回结果为0表示离线,1表示在线。
其他细节可参阅:http://www.allesta.net:51110/webservices/wsdl/YahooUserPingService.xml
四、参考:
The SOAP specification Simple Object Access Protocol (SOAP) 1.1 - W3C Note :
http://www.w3.org/TR/SOAP
Microsoft SOAP Toolkit Download :
http://download.microsoft.com/download/xml/soap/2.0/w98nt42kme/EN-US/SoapToolkit20.exe
五:本文示例的SOAP代码:
#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 main()
{
CoInitialize(NULL);
ISoapSerializerPtr Serializer;
ISoapReaderPtr Reader;
ISoapConnectorPtr Connector;
// 连接服务器
Connector.CreateInstance(__uuidof(HttpConnector));
Connector->Property["EndPointURL"] = "http://www.allesta.net:51110/webservices/soapx4/isuseronline.php";
Connector->Connect();
// 启动消息机制
Connector->Property["SoapAction"] = "uri:allesta-YahooUserPing";
Connector->BeginMessage();
// 创建SoapSerializer对象
Serializer.CreateInstance(__uuidof(SoapSerializer));
// 与输入流连接
Serializer->Init(_variant_t((IUnknown*)Connector->InputStream));
// 制作SOAP信息
Serializer->startEnvelope("","","");
Serializer->startBody("");
Serializer->startElement("isuseronline","uri:allesta-YahooUserPing","","m");
Serializer->startElement("username","","","");
Serializer->writeString("laghari78");
Serializer->endElement();
Serializer->endElement();
Serializer->endBody();
Serializer->endEnvelope();
// 向服务器发送信息
Connector->EndMessage();
// 读取回应
Reader.CreateInstance(__uuidof(SoapReader));
// 连接输出流
Reader->Load(_variant_t((IUnknown*)Conne