The gSOAP toolkit simplifies the development and deployment of SOAP/XML Web Services and client applications in C and C++. The gSOAP RPC compiler does all the difficult work for you. It generates the necessary C and C++ source codes to seamlessly glue your C/C++ applications to the SOAP/XML Web Services stack. With the compiler you can enable your (existing) C and/or C++ applications to “talk SOAP”!.

gSOAP is not just a class library. The gSOAP RPC compiler produces routines to encode native and user-defined C/C++ types in XML. To make things even easier, gSOAP provides memory management with garbage collection so (XML-decoded) data can be cleaned up without a hassle.

Calling WCF Services from a Linux C++ Client Using gSOAP

Step 1: Build a server Web service by WCF

First, you need to make a server webservice by c#. Please follow this tutorial

When you finished to created a server. We will get link:

Step 2: Download the gSOAP tar file. The website is here.

Step 3: Generate the WSDL header file.

wsdl2h -o mywcfheader.h

Step 4: Generate the stub files by executing the gSOAP compiler

soapcpp2 -I “/lib/gSOAP/gsoap-2.7/gsoap/” mywcfheader.h

Step 5: Create the client

#include “BasicHttpBinding_IMyService.nsmap”

using namespace std;

int main()

    // This will be the name of the service
    // class in the proxy header file from above
    BasicHttpBinding_IMyService s;

    // This is the request and response that
    // the service you are trying to call takes.
    // Again you can find the types in the class
    // used in the C++ proxy header
    _ns1__GetCount req;
    _ns1__GetCountResponse resp;

    string is(”Hello There America”);
    req.inputString = &is;

    int err = s.__ns1__GetCount(&req, &resp);

    if (SOAP_OK == err)
        cout << “Service Returned: ” << *resp.GetCountResult << endl;
        cout << “Error: ” << err << endl;

    return 0;

Step 6: Compile the client

g++ -I "/lib/gSOAP/gsoap-2.7/gsoap" myclient.cpp soapC.cpp soapClient.cpp /lib/gSOAP/gsoap-2.7/gsoap/stdsoap2.cpp




Add a Comment