선택적 오류 매개 변수가 포함 된 SOAP 응답 구조가 있습니다. 구문 오류를 생성하지 않았기 때문에이 매개 변수를 축약했습니다. 두 클래스 모두 gsoap에 의해 생성됩니다.Gsoap에서 C++ 객체를 할당하는 방법
응답 개체
class SOAP_CMAC ns1__LoginResponse : public ns1__Response
{
public:
class ns1__Error *Error; /* optional element of type ns1:Error */
int *SessionID; /* SOAP 1.2 RPC return element (when namespace qualified) */ /* optional element of type xsd:int */
public:
virtual int soap_type() const { return 127; } /* = unique type id SOAP_TYPE_ns1__LoginResponse */
virtual void soap_default(struct soap*);
virtual void soap_serialize(struct soap*) const;
virtual int soap_put(struct soap*, const char*, const char*) const;
virtual int soap_out(struct soap*, const char*, int, const char*) const;
virtual void *soap_get(struct soap*, const char*, const char*);
virtual void *soap_in(struct soap*, const char*, const char*);
ns1__LoginResponse() { ns1__LoginResponse::soap_default(NULL); }
virtual ~ns1__LoginResponse() { }
};
오류 개체
class SOAP_CMAC ns1__Error : public xsd__anyType
{
public:
std::string *Code; /* optional element of type xsd:string */
std::string *Description; /* optional element of type xsd:string */
public:
virtual int soap_type() const { return 100; } /* = unique type id SOAP_TYPE_ns1__Error */
virtual void soap_default(struct soap*);
virtual void soap_serialize(struct soap*) const;
virtual int soap_put(struct soap*, const char*, const char*) const;
virtual int soap_out(struct soap*, const char*, int, const char*) const;
virtual void *soap_get(struct soap*, const char*, const char*);
virtual void *soap_in(struct soap*, const char*, const char*);
ns1__Error() { ns1__Error::soap_default(NULL); }
virtual ~ns1__Error() { }
};
내 서비스에서 오류를 감지 할 때 나는이 ns1__Error 객체를 할당해야합니다.
나는 soap_malloc
ns1__Error* err = (ns1__Error*)soap_malloc(soap_context, sizeof(ns1__Error));
를 사용하여 시도했지만 나는 이것이 치명적 결함이 실현. gsoap이 나중에 객체 메소드 중 하나를 호출하면 충돌이 발생합니다. 개체 생성자가 호출되지 않았습니다.
soap_malloc을 호출하면 new를 사용하여 생성자를 호출 한 다음 작동하지만 소멸자를 호출 할 곳이 없습니다.
void* errmem = soap_malloc(soap_context, sizeof(ns1__Error));
ns1__Error err= new (errmem) ns1__Error();
이 충돌하지만 gsoap 아직 나에게 그냥 할 수있는 메커니즘을 제공하지 않는 것, 나에게 클래스를 만들어 그렇게 내가 나 자신을 할당 할 필요가 만든 특히, 잘못된 느낌하지 않습니다. 또한 소멸자가 호출되지 않았기 때문에 할당 해제 시간에 내 객체를 잠재적으로 잘못된 상태로 유지합니다.
soap_new_Class 기능에 대한 이야기가 있습니다. 그러나 버전 2.8.18에서는이 기능을 볼 수 없습니다.
개체를 올바르게 할당하고 구성하고 소멸 시키도록 GPO를 어떻게 만들 수 있습니까? gsoap은 개체가 완료되면 정리할 수 있습니까?
NON 필수 ** bool ** 필드가 포함 된 wsdl 개체가 있습니다. gsoap은이 필드에 ** bool 포인터 **가있는 C++ 구조를 생성합니다. 그러나 나는'soap_new_std__bool' 메쏘드를 찾을 수 없습니다 : 그것은'new bool'을 사용할 것으로 기대합니까? –
@MarcoStramezzi 나는 내 자신의 질문에 대답 한 지 오래되었습니다. 당신은 확실히 원시 새로운'bool'을 사용해서는 안됩니다. 나는 무엇을해야할지 모르겠다. 아마도 생성 된 코드를 열고 법안에 맞는 함수를 찾아보십시오. 그렇지 않으면 c에서 malloc처럼 사용할 수있는 일반 할당 함수가있을 수 있으며 단지 크기를 제공합니다. –