0

We are trying to include custom defined header in gsoap structure. Below is our header definition:

typedef struct apollo__Header
{
   char *UserName;
   int VenueId;
   time_t TransactionTime;
};

struct SOAP_ENV__Header
{ 
   struct apollo__Header *apollo__Header 0; /* mustUnderstand */
};

We have generated envStub and other headers/code using soapcpp2 compiler with below command:

$(SOAPCPP2) -z1 -d env -p env $(GSOAP_HEADERS) env_soap.h
$(SOAPCPP2) -z1 -n -t -d gsoap $(GSOAP_HEADERS) apollo_soap.h

In client code we have initialized this header like below:

void
prepareSoapHeader(soap* soap, const rString username)
{
    //pProperties props = AppProps::getProperties();
    apollo__Header *header = (apollo__Header*)malloc(sizeof(apollo__Header));
    header->UserName = new char[username.length() + 1];
    strcpy(header->UserName, username.toCString());
    header->VenueId = 110;
    header->TransactionTime = 0;
    soap->header = (SOAP_ENV__Header*)malloc(sizeof(SOAP_ENV__Header));
    soap->header->apollo__Header = header;
}

Now when we call the web services on server, we are getting segmentation fault on server while accessing this header! Server Crashing here when below code gets executed:

int apollo__getAvailableTestIDs(soap* soap, apollo__vAvailableTestIDs &resp)
{
   apollo__Header *header = getSoapHeader(soap);       
   if(header != NULL){
        AccessLogger l(soap->peer,"getAvailableTestIDs", "", header->UserName);
   }
   else{
        AccessLogger l(soap->peer,"getAvailableTestIDs", "", "UNKNOWN_USER");
}

Debugging shows:

(gdb) p *soap->header->apollo__Header->UserName
Cannot access memory at address 0xc0de000001da1230
(gdb) p *soap->header->apollo__Header
Cannot access memory at address 0xc0de000001da1230

We tried to find out the root cause and found that Header is being initialized properly by printing it’s values in client code. However tcpdump shows that client is not sending header values to server, its like .

It seems like this is some configuration error. Can any help in pointing out what is going wrong here. Any help would be appreciated.

Thanks.

1 Answers1

0

If there are multiple .c files , and if it is a re-compilation , make sure that you have all the object files with the latest structure changes.

msraj
  • 37
  • 4