Web Service Client Library for C ++

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

Requirements

  • There must be a C ++ library
  • can be used to access any SOAP web service (so I can pass the URL, web service name, web service method, and all arguments as arguments to the function call)
  • can request a web service for its WSDL and return me the available method names, method arguments and their data types
  • simple design

To be more specific: a library should have simple calls like this to get 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.

+4
source share
1 answer

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

Provides mapping of XML Schema to C / C ++ using wsdl2h. It has good documentation and many samples in the package. Doc can also be found on the Internet . You can easily port your code on many operating systems (Linux, Windows, etc.).

Simpe example for adding to a number through a web service (call 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 work in two steps

  • First create stubs (e.g. wsdl2java) from WSDL
  • Then you call stubs with your objects

Also a great structure if you want to create your own service (act as a server, not just client code)

+7
source

Source: https://habr.com/ru/post/1394195/


All Articles