0

According to the gSOAP website the tools wsdl2h and soapcpp2 are used to generate the server-side of a webservice starting with a WSDL file. My question is, if it is possible to get auto-generated code that support JSON serialization.

I'm asking because the xml-rpc-json examples shipped with gSOAP use only basic data types. But I need complex types like an array of points Point(x,y)[] as input arguments of a server-side method.

Matthias
  • 5,574
  • 8
  • 61
  • 121

1 Answers1

0

The JSON support in gSOAP supports complex types, which are populated like hash maps. In C++ you simply manipulated these as maps:

struct soap *ctx = soap_new1(SOAP_C_UTFSTRING);
value v(ctx);
v["name"] = "john"; // a struct {"name": "john", "age": 24}
v["age"] = 24;
value point(ctx);
point[0]["x"] = 1.1; // an array of points (x,y)
point[0]["y"] = 3.2;
point[1]["x"] = 0.4;
point[1]["y"] = 7.3;

See the README.md in the samples in the gSOAP package, which includes extensive JSON examples.

Dr. Alex RE
  • 1,772
  • 1
  • 15
  • 23