I am developing a web service using gSOAP 2.8.8. I would like to send an unbounded sequence of a custom data type. I can implement this by following section 11.11 of gSOAP's User Guide like so:
class ns__InnerType {
std::string someStr;
int someInt;
};
class VectorOfInnerTypes {
ns__InnerType* __ptr;
int __size;
};
void ns__myMethod(VectorOfInnerTypes in, ns__EmptyResponse out);
This works well. However, since my program is in C++, I would like to take advantage of STL vectors. From everything I've read it appears that gSOAP supports serializing vectors. Here's what I believe should work:
#import "stlvector.h"
class VectorOfInnerTypes {
std::vector<ns__InnerType> mylist;
};
soapcpp2 is happy to compile this, and I am able to pass a C++ vector when calling the stub's myMethod
. However, here's what goes over the network:
<s:Envelope ...>
<s:Body s:EncodingStyle=...>
<q1:myMethod xmlns:q1="urn:ns"/>
</s:Body>
</s:Envelope>
Compare this to the network traffic when I use the __ptr
/__size
:
<SOAP-ENV:Envelope ...>
<SOAP-ENV:Body ...>
<ns:myMethod>
<mylist xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="ns:InnerType[3]">
<item>...</item>
<item>...</item>
<item>...</item>
</mylist>
</ns:myMethod>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
To get std::vector
to work, I've tried various combinations of:
std::vector<ns__InnerType> mylist;
std::vector<ns__InnerType*> mylist;
std::vector<ns__InnerType>* mylist;
std::vector<ns__InnerType*>* mylist;
with the requisite soap_new_std__vectorTemplate...
and soap_new_ns__InnerType
when preparing data on the client, but there's no improvement. It refuses to serialize correctly.
Both when it works (__ptr
/__size
) and when it doesn't (std::vector
), the invocation of myMethod
returns code 202, or HTTP Accepted.
How can I, and everyone who uses gSOAP in a C++ program, use STL vectors instead of the primitive __ptr
/__size
way? Any help would be much appreciated.