Интерфейс веб-сервиса с использованием GSOAP

#web-services #gsoap #strong-soap

#веб-сервисы #gsoap #strong-soap

Вопрос:

Я пытаюсь получить ответ от 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 DataManagementSoapProxyamp; rhs);
        /// Construct proxy given a managing context
        DataManagementSoapProxy(const struct soapamp;);

        ................
        ................
        /// 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 amp;tempuri__ReadTestDataResponse) { return this->ReadTestData(NULL, NULL, tempuri__ReadTestData, tempuri__ReadTestDataResponse); }
}
  

Два аргумента Structs для ReadTestData inside soapStub.h являются

 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 *ReadTestDataResu<
        /// 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
  

В моем приложении я попытался прочитать возвращаемую строку как

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

Возвращаемым значением должно быть {«Сообщение»: «Вы успешно подключились»}.

Но у меня есть result 0 возврат.

Что такое worng?

Комментарии:

1. У меня ошибка в виде SOAP 1.2 fault SOAP-ENV:Sender[no subcode] "OpenSSL not installed: recompile with -DWITH_OPENSSL" Detail: [no detail]

2. Я нашел решение в этом посте. https://cboard.cprogramming.com/c-programming/126883-problem-using-gsoap-openssl-linux.html