Я пытаюсь получить некоторые данные из заголовка SOAP, но получаю сообщение об ошибке, записанное в заголовке.
Я использовал gSOAP для создания правильного кода из файла wsdl, т. Е .:
...
wsdl2h -nMyNamespace -NMyNamespace -qMyNamespace -v -s -t ../gsoap_${GSOAP_VERSION}/typemap.dat -o MyNamespace_soap.h myWsdlFile.wsdl
soapcpp2 -n -pMyNamespace -qMyNamespace -I ../../gsoap/ -i -C MyNamespace_soap.h
...
В сгенерированном MyNamespace_soap.h вы можете найти следующее:
...
class MyNamespace__HeaderContent {
public:
char* headerContent1 0;
char* headerContent2 0;
char* headerContent3 0;
/// @todo <anyAttribute namespace="##any">.
/// @todo Schema extensibility is user-definable.
/// Consult the protocol documentation to change or insert declarations.
/// Use wsdl2h option -x to remove this attribute.
/// Use wsdl2h option -d for xsd__anyAttribute DOM (soap_dom_attribute).
@_XML __anyAttribute; ///< A placeholder that has no effect: please see comment.
/// A handle to the soap struct context that manages this instance when instantiated by a context or NULL otherwise (automatically set).
struct soap *soap;
};
...
mutable struct SOAP_ENV__Header {
MyNamespace__HeaderContent* MyNamespace__HeaderContent_;
};
...
и в MyNamespaceStub.h:
...
#ifndef WITH_NOGLOBAL
#ifndef SOAP_TYPE_MyNamespace_SOAP_ENV__Header
#define SOAP_TYPE_MyNamespace_SOAP_ENV__Header (150)
/* SOAP_ENV__Header: */
struct SOAP_CMAC SOAP_ENV__Header {
public:
/** Optional element 'MyNamespace:HeaderContent' of XSD type 'MyNamespace:HeaderContent' */
MyNamespace__HeaderContent *MyNamespace__HeaderContent_;
public:
/** Return unique type id SOAP_TYPE_MyNamespace_SOAP_ENV__Header */
int soap_type() const { return SOAP_TYPE_MyNamespace_SOAP_ENV__Header; }
/** Constructor with member initializations */
SOAP_ENV__Header() {
MyNamespace__HeaderContent_ = (MyNamespace__HeaderContent *)0;
}
/** Friend allocator used by soap_new_SOAP_ENV__Header(struct soap*, int) */
friend SOAP_FMAC1 SOAP_ENV__Header * SOAP_FMAC2 soap_instantiate_SOAP_ENV__Header(struct soap*, int, const char*, const char*, size_t*);
};
#endif
#endif
И последнее, но не менее важное: MyNamespaceProxy.h:
...
#ifndef MyNamespaceProxy_H
#define MyNamespaceProxy_H
#include "MyNamespaceH.h"
namespace MyNamespace {
class SOAP_CMAC Proxy : public soap {
public:
...
Proxy(const char *endpoint);
...
virtual int someServiceFunction(_MyNamespace__Request *MyNamespace__Request, _MyNamespace__Response &MyNamespace__Response) {
...
}
...
В своем коде я написал это (MyNamespace_service.cpp):
...
#include "MyNamespace_service.hpp"
#include "wsdl/MyNamespaceProxy.h"
#include "wsdl/MyNamespace.nsmap"
...
Proxy serviceProxy(config->MyServiceEndPointStr.c_str());
MyNamespace__HeaderContent *headerContent = NULL;
_MyNamespace__ServiceRequest request;
request.input1 = someVariable;
request.input2 = anotherVariable;
_MyNamespace__ServiceResponse response;
int soapReturn = serviceProxy.someServiceFunction(&request, response);
if (soapReturn == SOAP_OK) {
...
SOAP_ENV__Header *soapHeader = serviceProxy.soap_header(); // this works
headerContent = soapHeader->MyNamespace__HeaderContent_; // this fails
...
}
...
Компилятор выдает:
... error: invalid use of incomplete type ‘struct SOAP_ENV__Header’
headerContent = soapHeader->MyNamespace__HeaderContent_;
^
In file included from src/some_service/wsdl/MyNamespaceStub.h:24:0,
from src/some_service/wsdl/MyNamespaceH.h:16,
from src/some_service/wsdl/MyNamespaceProxy.h:16,
from src/some_service/MyNamespace_service.cpp:17:
./src/gsoap/stdsoap2.h:2577:10: note: forward declaration of ‘struct SOAP_ENV__Header’
struct SOAP_ENV__Header *header;
...
Может кто-нибудь помочь мне с этой проблемой?