csk
csk

Reputation: 418

Web service client library for C++

I'd like to implement a web service client for a project on Windows. I want to get web service info, soap request and soap response. I need a C++ library that I can use for these purposes (not wsdlpull).

Requirements:

To be more specific: library should have simple calls like this for getting web service information

invoker.getOperations(operations);

outputXml += "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n";
outputXml += "<webService";
outputXml += " name=\"" + GetServiceName(&invoker) + "\"";
outputXml += ">\n";
outputXml += "\t<webMethods>\n";

Thanks.

Upvotes: 6

Views: 13874

Answers (1)

cateof
cateof

Reputation: 6758

The industry standard for C/C++ web services is gsoap. http://www.cs.fsu.edu/~engelen/soap.html

Provides mapping XML Schema to C/C++ with wsdl2h. It has good documentation and a lot of samples in the package. Doc can be found also online. You can easily port your code in many OSs (linux, windows etc)

Simpe example to add to number via a web service (invocation code)

#include "soapH.h"
#include "calc.nsmap"
main()
{
   struct soap *soap = soap_new();
   double result;
   if (soap_call_ns__add(soap, 1.0, 2.0, &result) == SOAP_OK)
      printf("The sum of 1.0 and 2.0 is %lg\n", result);
   else
      soap_print_fault(soap, stderr);
   soap_end(soap);
   soap_free(soap);
}

With gsoap you do the job in two steps

  1. First create stubs (like wsdl2java) from the WSDL
  2. Then you call the stubs with your objects

Also excellent framework if you want to create your service (act as a server, not only client code)

Upvotes: 8

Related Questions