BizTalk Utilities CV ,   Jobs ,   Code library  
 
Home Page
WCF, WS, SOAP
Web Services
What Is SOAP?
Implementing a Web Service with Microsoft SOAP Toolkit Version 2
SOAP Services
Talking To HailStorm
Programming Web Services with SOAP
Limitations of the SoapFormatter
Creating Fault Messages
ServerFault Class
SoapFault Class
Sending RPC Responses
ISoapMessage Message Headers
Using the .NET SoapFormatter
Receiving an RPC message
Marshalling RPC With a Proxy
ISoapMessage (RPC) Interface
RPC using the NET SoapFormatter
SoapFormatter vs XmlSerializer
A Serialized SOAP Message
Retrieving Message Headers
<< Uncategorized
XALAN >>

By :Mark Wilson
I am the creator of TopXML. I am available for international and local (Australia) contracts. I am a Solution Architect/Business Analyst. I have worked in IT in several countries (NZ, Australia, South Africa, UK) building and training teams for government and very large non-governmental organizations. I am ex-Microsoft Consulting Services. I wrote the first book on Microsoft XML published in 2000 called XML Programming with VB and ASP. Most recently I have been building tools for the SEO industry. Ask me for a 37 point SEO health-checkup for your website.
First posted :02/23/2001
Times viewed :2201

 

 

  

C++ SOAP client for MS SOAP Toolkit 1.0

by Catalin Hatmanu

This is a C++ SOAP client for December 2000 release of MS SOAP Toolkit 1.0 using the wire transfer technique.

Requirements

Introduction

In July 2000 Microsoft released first version of SOAP Toolkit for Visual Studio 6.0. In September 2000 was released the beta 1 of SOAP Toolkit Version 1.0. In my opinion the most remarkable feature that was added is the SSL support. The most recent non-beta version is version from December 2000 with bug fixes and small changes in the exposed interfaces

The purpose of this article is to demonstrate the wire transfer technique using a C++ client using also ATL.

Many thanks to Peter Santos.

About the sample

MS provide for testing purposes an web service with service description located at web service The sample use this web service and demonstrate the execution of GetStockQuote method exposed by this web service The sample contain two methods Connect and GetStockMethod

Connect method

Method for obtaining the service description and URI listener from web service. These are two strings ( BSTRs ) that we will keep them for using in GetStockMethod

 

long                     nSuccess, item = 0;

CComVariant              varTemp;

 

ROPE::ISOAPPackagerPtr   packer;

CComPtr                  pIUnknown;

ROPE::IServiceDescriptorsPtr    pIServiceDescriptors;

ROPE::ISDEndPointInfoPtrpISDEndPointInfo;

USES_CONVERSION;

 

  try

  {

         HRESULT hr = packer.CreateInstance( ROPE::CLSID_SOAPPackager );

         

         //load service description from this web service

         hr = packer->LoadServicesDescription(ROPE::icURI, 

                                               bstrLocation, NULL, &nSuccess);

         if( nSuccess != 1 )

                 throw E_FAIL;

 

         //get service descriptors

         hr = packer->get_GetServiceDescriptors(ROPE::icENDPOINTINFO, &varTemp);

 

         pIUnknown.Attach( varTemp.pdispVal );

         pIUnknown.QueryInterface( &pIServiceDescriptors );

         

         //get first descriptor on the list

         VariantInit(&varTemp);

         hr = pIServiceDescriptors->get_Item(variant_t(item),&varTemp);

         pIUnknown.Detach();

 

         //get the endpoint(URI address) a.e. where the SOAP message will be sent

         pIUnknown.Attach( varTemp.pdispVal );

         hr = pIUnknown.QueryInterface( &pISDEndPointInfo );

         hr = pISDEndPointInfo->get_URI(&URI_LISTENER);

         

         //get the service description

         hr = packer->get_ServicesDescription(&bstrSrvDesc);

  }

  catch(...)

  {

         std::cout << "Connection failure ! "<< std::endl;

         return false;

  }

  std::cout << "Connection successfull "<< std::endl;

  return true;

  

GetStockMethod

Method for calling the exposed GetStockPrice method from web service. After creation of a new SOAPPackager object and loading the service description from the string obtained from Connect method, the payload will be created and posted (using a new created WireTransfer object )to the web service and the result will be displayed

 

  long           nSuccess;

   CComBSTR      bstrRequestStruct, bstrRequestPayload, bstrResponsePayload;

  CComVAriant varPrice;

  

  ROPE::ISOAPPackagerPtr packer;

  ROPE::IWireTransferPtr wireTrans;

 

    USES_CONVERSION;

 

  try

  {

         HRESULT hr = packer.CreateInstance( ROPE::CLSID_SOAPPackager );

 

         //load service description using the string from previous Connect method call

         hr = packer->LoadServicesDescription(ROPE::icSTRING, 

                                               bstrSrvDesc, NULL, &nSuccess);

         if( nSuccess != 1 )

                 throw E_FAIL;

         

         //seek in the service description 

         //the method structure a.e. what we need to call this method

         hr = packer->GetMethodStruct(CComBSTR("GetStockQuote"), ROPE::icINPUT, &bstrRequestStruct);

         

         // set method name 

         hr = packer->SetPayloadData(ROPE::icREQUEST, CComBSTR(""), CComBSTR("GetStockQuote"), bstrRequestStruct); 

 

         //set method parameters

         hr = packer->SetParameter(  ROPE::icREQUEST, CComBSTR("Symbol"), CComVariant("MSFT") );

         hr = packer->SetParameter(  ROPE::icREQUEST, CComBSTR("description"), CComVariant("any company") );

 

         //get the data that will be sended to web server( payload ) 

         hr = packer->GetPayload( ROPE::icREQUEST, &bstrRequestPayload);

 

         std::cout <<  W2A(bstrRequestPayload) << std::endl << std::endl;

         

         //post the payload

         wireTrans.CreateInstance( ROPE::CLSID_WireTransfer);

         hr = wireTrans->AddStdSOAPHeaders(URI_LISTENER,CComBSTR("GetStockQuote"),bstrRequestPayload.Length());

         hr = wireTrans->PostDataToURI(URI_LISTENER, bstrRequestPayload, &bstrResponsePayload);

 

         std::cout <<  W2A(bstrResponsePayload) << std::endl << std::endl;

 

         //this is the response from service 

         hr = packer->SetPayload( ROPE::icRESPONSE, bstrResponsePayload);

         

         //get return value

         hr = packer->GetParameter( ROPE::icRESPONSE, CComBSTR("result"), &varPrice);

         std::cout << W2A(varPrice.bstrVal) << std::endl;

  }

  catch(...)

  {

         std::cout << "Something wrong happened !" << std::endl<< std::endl;

  }

Conclusions

I hope you will find useful this approach

 

  

Rate this article on a scale of 1 to 10

Your vote :  


 

Recent Jobs

Integration Specialist Needed - Wor
Virtualization Server Infrastructur
A great opportunity to Digital Vide
here is a greate opportunity as a S
A great opportunity as a Network En

View all Jobs (Add yours)
View all CV (Add yours)




swimming pool contractor
chicago web site design
halloween masks
Web Hosting
help desk support
Christian Dior sunglasses
answering service


    Email TopXML  

Front Page Daily Stuff TopXML Forum XML blogs XML Newsgroups BizTalk Biztalk Utilities Biztalk Utilities Tutorial B2B SAP XML Microsoft .NET Dotnet System XML Soapformatter SQLXML XMLserializer XQuery PHP PHP SimpleXML PHP XML Dom PHP XML RPC PHP XSLT Java Java Java XML Xalan Microsoft ASP ASP Schemas XML SQL Server XML XMLDom XSL XSL Tutorial XSLT Stylesheets General Javascript CSS XHTML WAP