0

I'm writing a SOAP client. I'm using gSOAP version 2.7.17 and I have to stick to that version as the server is using this one and I cannot modify it as it is already running in the field.

When I do my SOAP call, I always receive empty answer! However, when I sniff the network, the XML answer seems correct:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:Supervisor="urn:Supervisor"
    xmlns:ActiveLogin="urn:ActiveLogin" xmlns:TechLogin="urn:TechLogin"
    xmlns:UMSLogin="urn:UMSLogin">
    <SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
        <unitCallResponse>
            <szServerName>UMS_DEV_LANCC2 (2)</szServerName>
            <dResponse>cUNITRETURNCODE_RESTARTIMMEDIATE</dResponse>
            <dDetail>cBla</dDetail>
        </unitCallResponse>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Here is a simplified code snippet about how I perform the SOAP call with the proxy generated with soapcpp2:

UMSLogin::unitCallResponse response;    // Response from SOAP
UMSLogin::UMSLoginProxy* m_soapProxy =  // The SOAP proxy
    new UMSLogin::UMSLoginProxy(SOAP_IO_KEEPALIVE, SOAP_IO_KEEPALIVE);

callRes = m_soapProxy->unitCall(m_eUnitType, serial, m_dInterfaceVersion,
    xl2CallTypeToUmsLoginCallType(m_pSoapEndPoint->getCallType()),
    xl2CommTypeToUmsLoginCommType(m_pSoapEndPoint->getComType()),
    response);

logDebug(LOG_COM_DEVICE, "SOAP call done to %s, SOAP code %i, central code %i",
    response.szServerName.c_str(), callRes, response.dResponse);

m_soapProxy->soap_close_socket();
m_soapProxy->destroy();
delete m_soapProxy;

The actual output:

SOAP call done to , SOAP code 0, central code 0

When I expect

SOAP call done to UMS_DEV_LANCC2 (2), SOAP code 0, central code 5
/* 5 ->  cUNITRETURNCODE_RESTARTIMMEDIATE */

There was an old implementation that was working previously, this must be working! Where am I wrong? Did anyone has already had this kind of problem? Any pointer is strongly appreciated!

EDIT:

Problem was "solved" by using an earlier version of SOAP (2.7.14) without changing a single line of code from the original version of my program. However, I have the feeling I miss something important again! I should probably tweak a little my header file giving the SOAP "definitions" to make things working ...

morandg
  • 1,066
  • 3
  • 14
  • 30

1 Answers1

0

Looking at your code you declare response and then reference the elements of it as response.dResponse. This seems to imply that response is a struct rather than a pointer to a struct so after you call m_soapProxy->unitCall the version of response that you then report on hasn't changed, only the copy in m_soapProxy->unitCall will have changed.

I'd try tracing this call through in the debugger and see what is actually happening in m_soapProxy->unitCall. BTW is it you code or generated by GSOAP?

Jackson
  • 5,627
  • 2
  • 29
  • 48
  • Thanks for the advice but I thought about this but "unitCall" needs a reference, so the variable is updated, see the signature -> UMSLoginProxy::unitCall(... , unitCallResponse &response). When I use a debugger, at the end of the unitCall method, generated by SOAP, it copies its temporary variable into my reference, and already at this time, the answer is empty! – morandg Jan 28 '13 at 15:00