I am trying to get response from webservice using Gsoap
.
SoapProxy.h
has a class
class SOAP_CMAC DataManagementSoapProxy : public soap {
public:
/// Endpoint URL of service 'DataManagementSoapProxy' (change as needed)
const char *soap_endpoint;
/// Variables globally declared in webservice.h, if any
/// Construct a proxy with new managing context
DataManagementSoapProxy();
/// Copy constructor
DataManagementSoapProxy(const DataManagementSoapProxy& rhs);
/// Construct proxy given a managing context
DataManagementSoapProxy(const struct soap&);
................
................
/// Web service synchronous operation 'ReadTestData' with default endpoint and default SOAP Action header, returns SOAP_OK or error code
virtual int ReadTestData(_tempuri__ReadTestData *tempuri__ReadTestData, _tempuri__ReadTestDataResponse &tempuri__ReadTestDataResponse) { return this->ReadTestData(NULL, NULL, tempuri__ReadTestData, tempuri__ReadTestDataResponse); }
}
The two Structs arguments for ReadTestData inside soapStub.h
are
class SOAP_CMAC _tempuri__ReadTestData {
public:
/// Context that manages this object
struct soap *soap;
public:
/// Return unique type id SOAP_TYPE__tempuri__ReadTestData
virtual long soap_type(void) const { return SOAP_TYPE__tempuri__ReadTestData; }
/// (Re)set members to default values
virtual void soap_default(struct soap*);
/// Serialize object to prepare for SOAP 1.1/1.2 encoded output (or with SOAP_XML_GRAPH) by analyzing its (cyclic) structures
virtual void soap_serialize(struct soap*) const;
/// Output object in XML, compliant with SOAP 1.1 encoding style, return error code or SOAP_OK
virtual int soap_put(struct soap*, const char *tag, const char *type) const;
/// Output object in XML, with tag and optional id attribute and xsi:type, return error code or SOAP_OK
virtual int soap_out(struct soap*, const char *tag, int id, const char *type) const;
/// Get object from XML, compliant with SOAP 1.1 encoding style, return pointer to object or NULL on error
virtual void *soap_get(struct soap*, const char *tag, const char *type);
/// Get object from XML, with matching tag and type (NULL matches any tag and type), return pointer to object or NULL on error
virtual void *soap_in(struct soap*, const char *tag, const char *type);
/// Return a new object of type _tempuri__ReadTestData, default initialized and not managed by a soap context
virtual _tempuri__ReadTestData *soap_alloc(void) const { return SOAP_NEW_UNMANAGED(_tempuri__ReadTestData); }
public:
/// Constructor with default initializations
_tempuri__ReadTestData() : soap() { }
virtual ~_tempuri__ReadTestData() { }
/// Friend allocator used by soap_new__tempuri__ReadTestData(struct soap*, int)
friend SOAP_FMAC1 _tempuri__ReadTestData * SOAP_FMAC2 soap_instantiate__tempuri__ReadTestData(struct soap*, int, const char*, const char*, size_t*);
};
#endif
/* webservice.h:162 */
#ifndef SOAP_TYPE__tempuri__ReadTestDataResponse
#define SOAP_TYPE__tempuri__ReadTestDataResponse (9)
/* complex XML schema type 'tempuri:ReadTestDataResponse': */
class SOAP_CMAC _tempuri__ReadTestDataResponse {
public:
/// Optional element 'tempuri:ReadTestDataResult' of XML schema type 'xsd:string'
std::string *ReadTestDataResult;
/// Context that manages this object
struct soap *soap;
public:
/// Return unique type id SOAP_TYPE__tempuri__ReadTestDataResponse
virtual long soap_type(void) const { return SOAP_TYPE__tempuri__ReadTestDataResponse; }
/// (Re)set members to default values
virtual void soap_default(struct soap*);
/// Serialize object to prepare for SOAP 1.1/1.2 encoded output (or with SOAP_XML_GRAPH) by analyzing its (cyclic) structures
virtual void soap_serialize(struct soap*) const;
/// Output object in XML, compliant with SOAP 1.1 encoding style, return error code or SOAP_OK
virtual int soap_put(struct soap*, const char *tag, const char *type) const;
/// Output object in XML, with tag and optional id attribute and xsi:type, return error code or SOAP_OK
virtual int soap_out(struct soap*, const char *tag, int id, const char *type) const;
/// Get object from XML, compliant with SOAP 1.1 encoding style, return pointer to object or NULL on error
virtual void *soap_get(struct soap*, const char *tag, const char *type);
/// Get object from XML, with matching tag and type (NULL matches any tag and type), return pointer to object or NULL on error
virtual void *soap_in(struct soap*, const char *tag, const char *type);
/// Return a new object of type _tempuri__ReadTestDataResponse, default initialized and not managed by a soap context
virtual _tempuri__ReadTestDataResponse *soap_alloc(void) const { return SOAP_NEW_UNMANAGED(_tempuri__ReadTestDataResponse); }
public:
/// Constructor with default initializations
_tempuri__ReadTestDataResponse() : ReadTestDataResult(), soap() { }
virtual ~_tempuri__ReadTestDataResponse() { }
/// Friend allocator used by soap_new__tempuri__ReadTestDataResponse(struct soap*, int)
friend SOAP_FMAC1 _tempuri__ReadTestDataResponse * SOAP_FMAC2 soap_instantiate__tempuri__ReadTestDataResponse(struct soap*, int, const char*, const char*, size_t*);
};
#endif
In my application, I tried to read the return string as
_tempuri__ReadTestData* a;
_tempuri__ReadTestDataResponse res;
int ret = webinf.ReadTestData(a, res);
if(ret==0)
std::cout << "result " << res.ReadTestDataResult << std::endl;
The return should be {"Message":"You have successfully connected"}.
But I have result 0
return.
What is worng?