WEB开发网
开发学院软件开发VC 用Visual C++建立SOAP客户端应用 阅读

用Visual C++建立SOAP客户端应用

 2008-11-13 19:34:31 来源:WEB开发网   
核心提示: http://www.w3.org/TR/SOAPMicrosoft SOAP Toolkit Download :http://download.microsoft.com/download/xml/soap/2.0/w98nt42kme/EN-US/SoapToolkit20.exe五

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 FilesCommon FilesMSSoapBinariesMSSOAP1.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*)Connector->OutputStream), "");
  
 // 显示结果
 printf("Answer: %sn", (const char *)Reader->RPCResult->text);
  CoUninitialize();
}

上一页  1 2 3 4 5 6 

Tags:Visual 建立 SOAP

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接