Simple gSOAP calculator Client and Service

Recently i started to reverse a binary that uses gSOAP library for webservice request handling. The product is written in C++ and gSOAP code is also generating C++ code for client/server interaction. I had the experience of auditing application that uses gSOAP but mostly client side code. This time i am faced with the gSOAP server side binary code and that too C++ generated code.

Googled internet to find a simple C++ generated client/server code so that i can map the generated code structures with the binary. Unfortunately i couldn’t one. So i started to read the documentation and generated code for simple Calc Client/Server.  I used the WSDL from and i have modified this file to point to local server.


Modification to calc.wsdl:

<service name="calc">
<documentation>gSOAP 2.7.9k generated service definition</documentation>
<port name="calc" binding="tns:calc">
  <SOAP:address location=""/>

Server Code:

/* CalcServer1.cpp */
#include "soapCalcService.h" // get server object
#include "calc.nsmap" // get namespace bindings

int main()
    calcService c;
    return c.serve(); // calls soap serve to serve as CGI application (using stdin/out)

// The ‘add’ service method (soapcpp2 w/ option -i)
int calcService::add(double a, double b, double &result)
    result = a + b;
    return SOAP_OK;

int calcService::sub(double a, double b, double &result)
    // dummy
    return SOAP_OK;

int calcService::mul(double a, double b, double &result)
    // dummy
    return SOAP_OK;

int calcService::div(double a, double b, double &result)
    // dummy
    return SOAP_OK;

int calcService::pow(double a, double b, double &result)
    // dummy
    return SOAP_OK;

Client Code:

/* CalcClient.cpp */
#include "soapcalcProxy.h"
#include "calc.nsmap"
void main()
    calcProxy service;
    double result;
    if (service.add(1.0, 2.0, result) == SOAP_OK)
        std::cout << "The sum of 1.0 and 2.0 is " << result << std::endl;


C:\gsoap-2.8\gsoap\bin\win32\wsdl2h.exe -s -o calc.h calc.wsdl
C:\gsoap-2.8\gsoap\bin\win32\soapcpp2.exe -i calc.h
cl CalcClient.cpp soapC.cpp stdsoap2.cpp soapcalcProxy.cpp
cl  CalcServer1.cpp stdsoap2.cpp soapcalcService.cpp soapC.cpp

This entry was posted in gSOAP and tagged , . Bookmark the permalink.

4 Responses to Simple gSOAP calculator Client and Service

  1. what do the command “cl” makes?
    i receive the response:
    Unrecognized command line argument ‘CalcClient.cpp’ 3.018 — shell wrapper generator for Common Lisp software

    For help, invoke script with help argument:
    /usr/bin/cl -h

  2. sandeep says:

    Thanks for Article. It was good to start off with.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s