intelliproject logo

Location: Desktop development - C/C++    License: The Intelliproject Open License (IPOL)

Building A SOAP Client With Visual C++

Posted by Caragea Silviu

A simple way to create a SOAP client using C++

Skill: Advanced

Posted: 04/10/2008

Views: 160

Rating: 5.00 /5

Popularity: 0.00

Sign Up to vote for this article

Introduction

SOAP is an acronym that comes from "Simple Object Access Protocol". It's used for exchanging XML-based messages over computer networks, normally using HTTP/HTTPS. SOAP forms the foundation layer of the web services protocol stack providing a basic messaging framework upon which abstract layers can be built.

The advantages of using SOAP technology

  • Using SOAP over HTTP allows for easier communication through proxies and firewalls than previous remote execution technology.
  • SOAP is versatile enough to allow for the use of different transport protocols. The standard stacks use HTTP as a transport protocol, but other protocols are also usable (e.g., SMTP).
  • SOAP is platform independent.
  • SOAP is language independent.
  • SOAP is simple and extensible.

The disadvantages of using SOAP technology

  • Because of the verbose XML format, SOAP can be considerably slower than competing middleware technologies such as CORBA. This may not be an issue when only small messages are sent.To improve performance for the special case of XML with embedded binary objects, Message Transmission Optimization Mechanism was introduced. Further, to improve the performance of XML in general, there are emerging non-extractive XML processing models, e.g., VTD-XML.
  • When relying on HTTP as a transport protocol and not using WS-Addressing or an ESB, the roles of the interacting parties are fixed. Only one party (the client) can use the services of the other. Developers must use polling instead of notification in these common cases.
  • Most uses of HTTP as a transport protocol are done in ignorance of how the operation would be modeled in HTTP[citation needed]. This is by design (with analogy to how different protocols sit on top of each other in the IP stack) but the analogy is imperfect (because the application protocols used as transport protocols are not really transport protocols). Because of this, there is no way to know if the method used is appropriate to the operation. This makes good analysis of the operation at the application-protocol level problematic at best with results that are sub-optimal (if the POST-based binding is used for an application which in HTTP would be more naturally modeled as a GET operation).
  • Because SOAP uses HTTP, a firewall designed to only allow web browsing cannot simply allow all HTTP-using packets; instead it has to perform more detailed (and thus less efficient) packet analysis.

Building A SOAP Client with Visual C++

If you want to build a SOAP client you can choose to use different open source solutions available on internet. Also you can opt for Microsoft SOAP Toolkit which is a set of DLLs which can be exploited from an any language within the COM (Component Object Model) family (as long, of course, as the executable is running on a Win32 system).

In this article I will show you a more simple method (in my opinion) based on IXMLHTTPRequest which provides client-side protocol support for communication with HTTP servers.

Using the code

The above class is a very useful wrapper for IXMLHTTPRequestPtr. It has just two methods:

  • HRESULT Connect(char *szServer , char * szAction) used to initialize the connection.
  • HRESULT SendXMLConntent(_bstr_t xmlContent , _bstr_t &respond) used to send and receive the xml content.

Before creating any CSoapBase instance do not forget to initialize the COM library using     CoInitialize or CoInitializeEx.
In the source code attached to this article you can find an example which use CSoapBase to login on www.betfair.com using Betfair API SOAP server.

After you receive the xml content you can use any XML parser available on internet to parse it.

License

This article, along with any associated source code and files, is licensed under The Intelliproject Open License (IPOL)

About the author

Caragea Silviu

Caragea Silviu is the Fondator, Administrator and Chief Editor who wrote and runs The IntelliProject.

He's been programming since 2000 and now he's student at The Faculty of Economic Cybernetics, Statistics and Informatics from Bucharest. In the same time he's working as software developer at Cratima Software, a Romanian software and web design company that activates both on the local and foreign market, providing its customers with software development services, internet and intranet solutions, web design, graphic design and IT consultancy.

His programming experience includes:
- C,C++, Visual C++(Win32 API, MFC, ADO, STL, DAO, ODBC, ATL, COM, DirectShow, DirectDraw, WTL)
- Open Source libraries :CURL & Boost
- HTML, CSS
- Java (SE,ME)
- JavaScript, Ajax, Google Web Toolkit (GWT)
- Php, MySQL
-Oracle, PL SQL
- C# .NET
-Objective C, IPhone SDK, Cocoa

Location: Romania
Ocupation: Software Engineer
Home page: http://www.intelliproject.net

Sign up to post message on the article message board!