用Visual C++建立SOAP客户端应用
2008-11-13 19:34:31 来源:WEB开发网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();
}
- ››Visual Basic 2008 数学函数
- ››Visual Studio2005中Smart Device的问题
- ››Visual Studio 中根据数据库字段动态生成控件
- ››Visual Studio 11全新黑色主题
- ››Visual Studio 2011 Beta新特性(一):安装VS201...
- ››建立唯美图片特效,十个jQuery插件分享
- ››Visual Studio自定义调试窗体两个小技巧
- ››Visual Studio 2005 Team Edition for Database P...
- ››Visual C#两分钟搭建BHO IE钩子
- ››建立自己的TextView和ImageView的组合View类
- ››Visual C++优化对大型数据集合的并发访问
- ››VISUAL C++中的OCX控件的使用方法
更多精彩
赞助商链接