使用GSOAP的Web服务接口

问题描述

我正试图从webservice using Gsoap得到答复。

SoapProxy.h一个课程

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); }
}

ReadTestData inside soapStub.h的两个Structs参数是

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*,int id,const char *type) const;
        /// Get object from XML,return pointer to object or NULL on error
        virtual void *soap_get(struct soaP*,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 *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*,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,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*,size_t*);
};
#endif

在我的应用程序中,我尝试将返回字符串读取为

  _tempuri__ReadTestData* a;
  _tempuri__ReadTestDataResponse res;
  int ret = webinf.ReadTestData(a,res);
  if(ret==0)
    std::cout << "result " << res.ReadTestDataResult << std::endl;

返回应为{“ Message”:“您已成功连接”}。

但是我有result 0个退货。

这是什么?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)