打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
vc中如何调用webservice? VC/MFC / 进程/线程/DLL
用msxml+soap  
  #import   "msxml4.dll"    
  using   namespace   MSXML2;  
  #import   "C:\Program   Files\Common   Files\MSSoap\Binaries\mssoap30.dll"   \  
                          exclude("IStream",   "IErrorInfo",   "ISequentialStream",   "_LARGE_INTEGER",   \  
                                          "_ULARGE_INTEGER",   "tagSTATSTG",   "_FILETIME")  
  using   namespace   MSSOAPLib30;  
   
   
  string   GetCompanyNameFromWeb(void)  
  {  
  try  
  {  
  ISoapSerializerPtr   Serializer;  
  ISoapReaderPtr   Reader;  
  ISoapConnectorPtr   Connector;  
  //   Connect   to   the   service.  
  Connector.CreateInstance(__uuidof(HttpConnector30));  
  //Connector->Property["EndPointURL"]   =   "http://www.mainone.com/UpLoadImage.asmx";  
  Connector->Property["EndPointURL"]   =   "http://localhost/WebOfficeValidateService/Validate.asmx";  
  Connector->Connect();  
   
  //   Begin   the   message.  
  Connector->Property["SoapAction"]   =   "http://tempuri.org/GetCompanyName";  
  Connector->BeginMessage();  
   
  //   Create   the   SoapSerializer   object.  
  Serializer.CreateInstance(__uuidof(SoapSerializer30));  
   
  //   Connect   the   serializer   object   to   the   input   stream   of   the   connector   object.  
  Serializer->Init(_variant_t((IUnknown*)Connector->InputStream));  
   
  //   Build   the   SOAP   Message.  
  Serializer->StartEnvelope("","","");  
  Serializer->StartBody("");  
  Serializer->StartElement("GetCompanyName","http://tempuri.org/","","");  
  Serializer->StartElement("SerialNum","http://tempuri.org/","","");  
  Serializer->WriteString(m_strSerial.c_str());  
  Serializer->EndElement();  
  Serializer->EndElement();  
  Serializer->EndBody();  
  Serializer->EndEnvelope();  
   
  //   Send   the   message   to   the   XML   Web   service.  
  Connector->EndMessage();  
   
  //   Read   the   response.  
  Reader.CreateInstance(__uuidof(SoapReader30));  
   
  //   Connect   the   reader   to   the   output   stream   of   the   connector   object.  
  VARIANT_BOOL   bl   =   Reader->Load(_variant_t((IUnknown*)Connector->OutputStream),   "");  
   
   
  //   Display   the   result.  
  _bstr_t   bstrResult   =   Reader->RpcResult->text;  
  return   (char*)bstrResult;  
  }  
  catch(_com_error   &e)  
  {  
  return   NULL;  
  }  
  }  
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
[原创&交流]桌面程序调用Web Service应用实例
VC下ADO数据库操作的封装类
孙鑫VC学习笔记:第二十讲 (二) ado数据库编程
VC++中 ado 访问mdb数据库(转) - wwqiang2003的日志 - 网易博客
windows server 2008 ado 操作做数据 CreateInstance("ADODB.Connection"); 失败
產生msxml3.dll 錯誤 '800c0005'有以下幾種原因:
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服