Skip to main content
Email Password   helpLost your password?

Introduction

In this article, I explain how to build a web service client from a WSDL file. I am releasing this project to help those who wish to begin to use a web service with gSOAP. I won't, however, be explaining about XML Serialization, Transient Types, Memory Management, etc.

I split the article into two parts for easier learning and better understanding. In Part One, I will explain how to get the class from the WSDL file to be used in Visual C++ 6. In Part Two, I show you how to use the classes generated with gSOAP.

To begin, you will want:

Info: I used a free web service from WebserviceX.NET. If their server is busy and you get the the error "service unavailable," see if it's working here. After downloading the file, you have to build a C++ class from the WSDL file. Go to the gSoap directory and open the bin sub-folder, something like this: D:\gsoap-win32-2.7\bin. Here, you find two executable files:

WSDL Importer: Generate the File with C++ Bindings

Copy the WSDL to this directory and run wsdl2h.exe like this:

wsdl2h -o WSCurrencyConv.h CurrencyConvertor.wsdl 
Sample use of wsdl2h

In the shell, you'll see some warning (ignore this) and at the end "To complete the process, compile with: soapcpp2 WSCurrencyConv.h". If all works fine, you'll see a new file in the directory that will be WSCurrencyConv.h (or the name you write at the command line).

N.B. You shouldn't have problems, but if you do, check the name and path you entered and try again.

gSOAP Compiler: Generate the Proxy and XML Serialization Routines in Source-code Format

Run soapcpp2.exe like this:

soapcpp2 -ID:\gsoap-win32-2.7\Import WSCurrencyConv.h
Sample use of soapcpp2

To run this executable, you need to set the path for the gSOAP import, something like this: D:\gsoap-win32-2.7\import. This is similar to what I did before with:

-ID:\gsoap-win32-2.7\Import

The second parameter is the file *.h you entered the first time with wsdl2h. If it works, you'll see in the last line "Compilation successful". Now in the directory, you'll see a few new files.

N.B. You shouldn't have problems, but if you do, check that the path for the import file exists. Otherwise, you can copy all the files in the import directory to the bin directory and try again.

The new files will be:

Using the Visual C++

Now you have all you want to begin deploying your application with Visual C++.

Include Self-generated Code into Visual C++ Projects:

  1. You need to include in your application the files below:
  2. Set the no precompiler header for the CPP files before: VC++ settings
  3. Set the Namespace, select the file stdafx.cpp and include the file CurrencyConvertorSoap.nsmap with this line:
  4. Link Ws2_32.lib to the project for use the Windows Sockets 2 API: VC++ settings

The Project is ready to communicate with the WS. You have all the classes you need to begin.

N.B You could get this warning (shown below), but don't worry and go ahead. This warning is derived from the self-generated class with gSOAP; gSOAP doesn't check the maximum characters.

Warning

Points of Interest

I read many books online. I find that there are numerous mistakes and that all the examples are unusable. These books may have all you want to know in order to pass a university test, but there is too much information to begin a project. Irritated, I did this project to let you to begin to write a WS client.

History

You must Sign In to use this message board.
 
 
Per page   
 FirstPrevNext
GeneralI have an error when getting the conversion rate. Pin
waleed82
3:19 16 Aug '09  
GeneralRe: I have an error when getting the conversion rate. Pin
Dr.Luiji
11:27 16 Aug '09  
GeneralRe: I have an error when getting the conversion rate. Pin
waleed82
22:14 16 Aug '09  
AnswerRe: I have an error when getting the conversion rate. Pin
Dr.Luiji
8:09 17 Aug '09  
QuestionHttps ceritification question Pin
Jenny_air
5:28 31 Jul '09  
AnswerRe: Https ceritification question Pin
Dr.Luiji
12:24 31 Jul '09  
GeneralRe: Https ceritification question Pin
Jenny_air
17:26 31 Jul '09  
GeneralRe: Https ceritification question Pin
Dr.Luiji
4:22 1 Aug '09  
GeneralgSOAP for TCP binding and callback events. Pin
BicycleTheif
19:49 6 Jul '09  
GeneralRe: gSOAP for TCP binding and callback events. Pin
Dr.Luiji
23:26 6 Jul '09  
GeneralRe: gSOAP for TCP binding and callback events. Pin
BicycleTheif
21:59 8 Jul '09  
GeneralRe: gSOAP for TCP binding and callback events. Pin
Dr.Luiji
2:48 9 Jul '09  
GeneralgSOAP proxy for WCF server with TCP binding and callback events Pin
BicycleTheif
19:45 6 Jul '09  
Generalavoiding the namespace binding in all the method calls??? Pin
naveen_naik
3:13 17 Dec '08  
GeneralRe: avoiding the namespace binding in all the method calls??? Pin
Dr.Luiji
12:43 17 Dec '08  
GeneralIgnoring certificate errors using SOAP in Visual C++ 6. Pin
Wahaj Khan
21:30 3 Dec '08  
GeneralRe: Ignoring certificate errors using SOAP in Visual C++ 6. Pin
Dr.Luiji
22:03 3 Dec '08  
GeneralRe: Ignoring certificate errors using SOAP in Visual C++ 6. Pin
Wahaj Khan
3:20 4 Dec '08  
AnswerRe: Ignoring certificate errors using SOAP in Visual C++ 6. Pin
Renata
22:49 3 Dec '08  
GeneralRe: Ignoring certificate errors using SOAP in Visual C++ 6. Pin
Wahaj Khan
3:19 4 Dec '08  
GeneralA link error in soapServer.obj Pin
Renata
5:20 3 Dec '08  
GeneralRe: A link error in soapServer.obj Pin
Dr.Luiji
22:13 3 Dec '08  
GeneralRe: A link error in soapServer.obj Pin
Renata
22:27 3 Dec '08  
Questioncompile error, help Pin
CharlieLei
13:22 2 Nov '08  
AnswerRe: compile error, help Pin
Dr.Luiji
1:12 4 Nov '08  


Last Updated 23 Mar 2007 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2009