Mac

December 22, 2009

Writing a simple SOAP client / server in C++ using gsoap

Filed under: Uncategorized — mac @ 7:02 pm

This is how I wrote a simple SOAP server in C++ using gsoap on my Debian Lenny server.

Preparing things

gsoap can be easily installed with the usual apt-get install gsoap

My service will be defined based on O’Reilly’s sample HelloService.wsdl which is available in Web Services Essential

Generating the skeleton files

The header file can be generated based on the .wsdl with the help of wsdl2h:

wsdl2h -o header.h HelloService.wsdl

Then it’s possible to generate the skeleton .ccp files with gsoap:

soapcpp2 -I/usr/include/gsoap header.h

You’ll note as well many other files generated - including .xml with sample queries, .h files…

Generating a command-line server

For a start we’re going to generate a command-line SOAP server.

All you need is to create a file named HelloServiceCLIServer.cpp with the following content:

// Contents of file "HelloService.cpp":
#include "soapH.h"
#include "Hello_USCOREBinding.nsmap"
main ()
{
soap_serve (soap_new ());
}

int ns1__sayHello (struct soap *soap, std::string firstName,
std::string & greeting)
{
greeting = "Hello my dear " + firstName + ".";
return SOAP_OK;
}

Then compile with:

g++ -lgsoap++ -lgsoapck++ HelloServiceCLIServer.cpp /usr/include/gsoap/stdsoap2.cpp soapC.cpp soapServer.cpp -o HelloServiceCLIServer

All done - you can test you server by using the sample .xml request file provided (it has an empty name, but that’s good enough for a crude test):

cat Hello_USCOREBinding.sayHello.req.xml | ./HelloServiceCLIServer

You will see a SOAP answer with the expected greeting (Hello my dear .)

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google]

November 11, 2009

How to identify un-used indexes in PostgreSQL

Filed under: Uncategorized — mac @ 4:42 pm

October 5, 2009

Free Icons!

Filed under: Uncategorized — mac @ 4:47 pm

August 21, 2009

DIV made easy - at least

Filed under: Uncategorized — mac @ 2:29 pm

August 17, 2009

How to convert a bigint into an inet in postgresql ?

Filed under: Uncategorized — mac @ 12:29 pm

August 14, 2009

How to ignore a directory in Subversion

Filed under: Uncategorized — mac @ 4:43 pm

July 24, 2009

Rebuilding a Debian Package

Filed under: Uncategorized — mac @ 11:40 am

June 29, 2009

Monitoring tools

Filed under: Uncategorized — mac @ 10:37 pm

June 11, 2009

Installing Linux Debian Lenny on an Alix board

Filed under: Uncategorized — mac @ 3:42 pm

May 20, 2009

Getting movie trailers…

Filed under: Uncategorized — mac @ 10:29 am
Next Page »

Powered by WordPress