VC6.0下访问WebService的组件

//WEB_SERVICE     #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;       //END         CString   BeginSoap(CString   UserName,CString   Password,CString   WebUrl);     ISoapConnectorPtr   SoapConnector;     ISoapSerializerPtr   Serializer;     ISoapReaderPtr   Reader;         CString   CXXXXXXXDlg::BeginSoap(CString   UserName,CString   Password,CString   WebUrl)     {     HRESULT hr;         CString   theSoapBody;         theSoapBody.Format(_T("<soap:Body><GetCSLoginTickets   xmlns=/"http://tempuri.org//"><LogonName>%s</LogonName><Pwd>%s</Pwd></GetCSLoginTickets></soap:Body>"),UserName,Password);             //创建SoapConnector类的对象     SoapConnector.CreateInstance(__uuidof(HttpConnector));           //指定Web 服务 的地址     SoapConnector->Property   ["EndPointURL"]   =(LPSTR)(LPCTSTR)WebUrl;         //与Web服务连接     hr=SoapConnector->Connect();     if(FAILED(hr))   return   NULL;         //指定Web服务完成的操作     SoapConnector->Property   ["SoapAction"]   =   _T("http://tempuri.org/GetCSLoginTickets");         //准备发送消息给Web服务     SoapConnector->BeginMessage();         //   创建SoapSerializer对象     Serializer.CreateInstance(__uuidof(SoapSerializer));           //   将serializer连接到connector的输入字符串     Serializer->Init(_variant_t((IUnknown*)SoapConnector->InputStream));           //   创建SOAP消息             Serializer->startEnvelope("soap","NONE","");                   Serializer->SoapNamespace("xsi","http://www.w3.org/2001/XMLSchema-instance");             Serializer->SoapNamespace("xsd","http://www.w3.org/2001/XMLSchema");         Serializer->writeXML((LPSTR)(LPCTSTR)theSoapBody);                 Serializer->endEnvelope();               //消息真正地发给Web服务     hr=SoapConnector->EndMessage();       if(FAILED(hr))   return   NULL;         //   读取响应     Reader.CreateInstance(__uuidof(SoapReader));           //   将reader联接到connector的输出字符串     Reader->Load(_variant_t((IUnknown*)SoapConnector->OutputStream),   _T(""));               return   CString((const   char   *)Reader->RPCResult->text);         }
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值