Click here to Skip to main content
12,950,618 members (62,026 online)
Click here to Skip to main content
Add your own
alternative version


22 bookmarked
Posted 4 Aug 2001

IsoapTypeMapper interface – a C++ implementation

, 4 Aug 2001
Rate this:
Please Sign up or sign in to vote.
This article I provides an implementation of the ISoapTypeMapper interface in C++ for serializing custom objects into XML and sending them over the wire using SOAP.
<!-- Download Links -->


Recently, I have been doing a lot of reading on SOAP and trying to familiarize myself with the MS SOAP Toolkit (version SP2). The samples that come with the toolkit are pretty neat, in that they have quite a bit of C++ samples too. As with any distributed application the fun lies in passing complex types as arguments to methods over the wire as opposed to primitive data types. In this article I have provided an implementation of the ISoapTypeMapper interface in C++ (using ATL)  for serializing custom objects into XML and sending them over the wire using SOAP. This article assumes that the reader is familiar with SOAP, ATL and with the set up of IIS for running the SOAP apps and has the MSSOAP toolkit SP2 installed.

The project

This project, as will be evident, is made up just to illustrate the implementation of the ISoapTypeMapper interface in C++ for complex objects. The aim of this article is to show you how to serialize two COM objects (namely Address and Dealer) into XML and send them over the wire using SOAP. The description of the two objects is shown below :

  • The Address object has 5 properties namely "Name", "Street", "City", "State" and "Zip" all defined as strings.

  • The Dealer object has 2 properties namely "Id" as string and "Address" as the above defined "Address" object.

The VC++  project shows the implementation of these objects and also the implementation of 2 other objects namely AddressMapper and DealerMapper which actually implement the ISoapTypeMapper interface and help in serializing the "Address" and "Dealer" objects respectively into XML.

There are two VB projects one called CPlusPlusAddress.vbp and the other Client.vbp. The CPlusPlusAddress.vbp is an ActiveX DLL project which is the Web Service implementation. It basically consists of 4 methods whose functionality is defined below:

  1. ProcessAddress
    - accepts an Address object as parameter and return a String which is actually a concatenation of all strings which make up the Address object.
  2. EchoAddress
    -- accepts an Address object as parameter and returns the same the Address object.
  3. ProcessDealer
    -- accepts a Dealer object as parameter and return a String which is actually a concatenation of all strings which make up the Dealer object.       
  4. EchoDealer
    -- accepts a Dealer object as parameter and returns the same the Dealer object.

The other VB project Client.vbp is a standard EXE and invokes the methods exposed the CPlusPlusAddress Web Service.

Getting Started

First compile the C++ project which actually registers the type mappers and the Address and Dealer COM objects used by the Web Service and the client. Then compile the CPlusPlusAddress.vbp project and ideally you will need to generate the .wsdl and .wsml files. But the project contains the files in the WSDL folder. Make sure create a virtual directory in IIS and name it CPPAddress. This virtual directory must actually point to the WSDL folder which contains the wsdl and wsml files. Then compile the Client.vbp project and you should be able to run the application.

The AddressMapper object

The code for the AddressMapper object is pretty self explanatory. The workings of the relevant individual  methods of the ISoapTypeMapper interface are explained below:

Init() - Since the all properties in Address object are strings we simply retrieve the string mapper that comes with Soap toolkit and store it in the m_pStringMapper element.

read() - the read method just reads the values in the incoming node object and builds an Address object with the values and return it.

write() - the write methods reads the values of the individual properties of the Address object and writes the XML to be sent over the wire.

The DealerMapper object

The workings of the DealerMapper object are similar to that of the AddressMapper object. The DealerMapper object uses the

object to serialize/deserialize the Address part of the Dealer object.


The article itself doesn't do much more than describe the projects that make up the code. The code is very self explanatory. I decided to do this since I found a lot of queries regarding serializing complex data types using C++, which went unanswered in the SOAP mailing lists maintained by Develop Mentor. I spent 2-3 days just trying to find an implementation on the Internet. I hope this sample helps the other folks like me who are frustrated (the way I was ) on not being able to find pointers on doing this using VC++/ATL.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Avinash Lakshman
United States United States
No Biography provided

You may also be interested in...


Comments and Discussions

GeneralUsing UDT for webservice methods Pin
aslamshikoh28-Dec-07 9:25
memberaslamshikoh28-Dec-07 9:25 
GeneralThank you Pin
Ken M12-Dec-07 19:25
memberKen M12-Dec-07 19:25 
GeneralcomplexTypes with XML-Element-Attributes? [modified] Pin
Thomson659628-Jun-06 0:45
memberThomson659628-Jun-06 0:45 
GeneralSOAP help Pin
hittmann4@hotmail.com8-Jul-04 21:09
memberhittmann4@hotmail.com8-Jul-04 21:09 
GeneralMore compile errors Pin
Jake Repp27-Aug-02 13:00
sussJake Repp27-Aug-02 13:00 
GeneralAbout handling soap:header Pin
Anonymous23-Sep-01 22:51
memberAnonymous23-Sep-01 22:51 
GeneralCompile errors Pin
Anonymous6-Aug-01 18:41
memberAnonymous6-Aug-01 18:41 
GeneralRe: Compile errors Pin
lijinniu28-Aug-02 16:45
memberlijinniu28-Aug-02 16:45 
GeneralObject-oriented database design and implementation Pin
kushibhai6-Aug-01 7:17
memberkushibhai6-Aug-01 7:17 
GeneralDead Link To Src Pin
Colin Beales6-Aug-01 4:16
memberColin Beales6-Aug-01 4:16 
GeneralRe: Dead Link To Src Pin
Chris Maunder6-Aug-01 4:34
memberChris Maunder6-Aug-01 4:34 
GeneralRe: Dead Link To Src Pin
Anonymous6-Jul-05 12:25
sussAnonymous6-Jul-05 12:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170525.1 | Last Updated 5 Aug 2001
Article Copyright 2001 by Avinash Lakshman
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid