How to use VC++6.0 to develop web Service Client

         If you wanna use VC++6.0 to develop application procedure of web service client,your machine have to install SOAP Toolkit3.0 and Microsoft XML Parser!The next task,I will discuss how to use Microsoft SOAP Toolkit3.0 to establish  a simple application procedure.

    First of all,you have to be familiar with how to use COM programme,especially the smart pointer of COM.I am gonna talk about sample class for SOAP.Before this,you have to import class type library that you need.The path is "C:/Program Files/Common Files/MSSoap/Binaries/MSSOAP1.dll"! The content of class type library will be translated or converted into COM smart pointer in order to describe

interface of COM.Because SOAP heavily depends on XML,you have to use Microsoft XML Parser to handle XML.Microsoft XML parser is contained in msxml3.dll file,which you should import before you import mssoap1.dll as following code:

  #import "msxml3.dll" <#import <msxml4.dll> some this like >
  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; <using namespace MSSOAPLib30>

  Above-mentioned code,you must contain on your application procedure  and

add them head file as usual.If you really wanna establish SOAP client application

procedure,you should complete the next three steps:

   1,Assigning and connect web service;

   2,Preparing and sending message;

   3,Reading information that returned from web service. I must introduce some classes for you before we start to write our main code.

   SoapConnectorPtr class.using it like this:

    1.Create object of SoapConnector class as following code:

      ISoapConnectorPtr Connector;
  Connector.CreateInstance(__uuidof(HttpConnector));

   2.Assign web address as following code:

     Connector->Property ["EndPointURL"] = "some url pointing to web service";

     If you wanna come to understand Property and the Value of Property,please check other reference.here,I just talk about address property.

   3.Connect web service like this:

      Connector->connect();

   4.Assign SoapAction like this:

     Connector->Property["SoapAction"] = "some url";

   5.Start up message handler:

     Connector->BeginMessage();

            here,you should add message code between BeginMessage() and     EndMessage() and in the and,the EndMessage() function will send message to web service.

  Above details/The remarks is about how to connect web service,and then,I will introduce how to create and prepare message.

  Using  SoapSerializer class establish SOAP message which will be send to web service.The Object of SoapSerializer class must connect with the Object of  SoapConnector class before communicating with web service.The initialization of

SoapSerializer will establish internal connection.the initialization parameter is

InputStream.

  Create object of SoapSerializer class and using InputStream initialize it as follow code:

   SoapSerializerPtr Serializer;

   Serializer.CreateInstance(_uuidof(SoapSerializer));

   Serializer->Init(_variant_t((IUnknown*)Connector->InputStream));

   SOAP request as following code:

    <SOAP: Envelope xmlns:SOAP="soap namespace">
  <SOAP:Body>
    <m:someMethodName xmlns:m="some namespace">
      <someParameter> someParameterValue </someParameter>
   <m:someMethodName>
  </SOAP:Body>
    </SOAP: Envelope>

But how to use this method?let's start to decribe them.

 Serializer->startEnvelope("SOAP","","");

 Serialzier->startBody("");                                              //the main information

Serializer->startElement("someMethodName","","","m");

Serializer->WriteString("someParameterValue") ;

 Serializer->writeString("do sth here...");

 

Serializer->endElement();
Serializer->endElement();
Serializer->endBody();
Serializer->endEnvelope();

Connector->EndMessage();// Return message to web service

The last step.we should read information that returned from web service.Using SoapReader class to read information.the next code is about response information by web service returned.

  <SOAP: Envelope xmlns:SOAP="soap namespace">
  <SOAP:Body>
     <m:someMethodNameResponse xmlns:m="some namespace">
       <return> someResult </return>
     <m:someMethodNameResponse>
  </SOAP:Body>
 </SOAP: Envelope>

Using OutputStream to read object of SoapReader information.Create object of

SoapReader class and connect OutputStream.

     ISoapReaderPtr Reader;
  Reader.CreateInstance(_uuidof(SoapReader));
  Reader->Load(_variant_t((IUnknown*)Connector->OutputStream));

      Reader->RPCResult->text ; //read text.

Above all these is about how to use SOAP .the next article,I will write some codes as example.See you next article.

  

  

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值