views:

576

answers:

0

Hello GSoap community!

My application is crashing when I am sending application specific fault details.

Here's how my SOAP_ENV__Detail looks like -

struct SOAP_ENV__Detail
{
public:
    ex__ExceptionType *ex__Exception; /* optional element of type ex:ex__ExceptionType */
    int __type; /* any type of element <fault> (defined below) */
    void *fault; /* transient */
    char *__any;
};

ex__ExceptionType just contains a string called Fault.

I have written a function to populate the soap fault. Here's how it looks - 

void GenSoapFault(soap * soap, string strErr, string strDetail, bool bSender)
{
    if(bSender)
     soap_sender_fault(soap, strErr.c_str(), NULL);
    else
     soap_receiver_fault(soap, strErr.c_str(), NULL);  

    ex__Exception * ptr = soap_new_ex__ExceptionType(soap, -1);
    ptr->Fault = strDetail;

    if (soap->version == 2) // SOAP 1.2 is used
    {
     soap->fault->SOAP_ENV__Detail = soap_new_SOAP_ENV__Detail(soap, -1);
     soap->fault->SOAP_ENV__Detail->__type = 0;
     soap->fault->SOAP_ENV__Detail->fault = NULL;
     soap->fault->SOAP_ENV__Detail->__any = NULL;
     soap->fault->SOAP_ENV__Detail->ex__Exception = ptr;
    }
    else 
    {
     soap->fault->detail = soap_new_SOAP_ENV__Detail(soap, -1); 
     soap->fault->detail->__type = 0;
     soap->fault->detail->fault = NULL;
     soap->fault->detail->__any = NULL;
     soap->fault->detail->ex__Exception = ptr;
    } 

}

After calling this function, I return SOAP_FAULT. And it seems to crash after this randomly. The code above is straight out of gsoap 2.7.11 documentation section 11 Soap Fault Processing and I cant quite fathom whats going wrong. I have already spent two days on this.

Can anyone please help me with this?

Thanks