Search code examples
gsoap

trying to understand gsoap


I am creating my first web service client using gsoap. I was able to the run the calc example provided with gsoap.

Now I am trying to access String GetData() function from WCF Webservice. I did the wsdl2h and soapcpp2 steps and have generated the .h file. In xxxxproxy.h I see that the prototype of GetData is as follows

/// Web service operation 'GetData' (returns error code or SOAP_OK)
    virtual int GetData(_ns1__GetData *ns1__GetData, _ns1__GetDataResponse *ns1__GetDataResponse);

Can someone tell me what should I write in my main.cpp to access GetData. I have following code in main.cpp

#include <QtCore/QCoreApplication>
#include "soapWSHttpBinding_USCOREIAquaLinkProxy.h"
#include "WSHttpBinding_USCOREIAquaLink.nsmap"

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    WSHttpBinding_USCOREIAquaLinkProxy webService;
    std::cout <<"Sent request"<<std::endl;
    std::string result;
    if(webService.GetData(?????? )==SOAP_OK)
    {
        std::cout << "Returned "<< ????? <<std::endl;
    }
    else
    {
        webService.soap_stream_fault(std::cerr);
    }
    return a.exec();
}

Thanks.


Solution

  • The first argument _ns1__GetData in the function GetData is the request argument, the second is the response argument. You should try following:

    _ns1__GetData request;
    request.???? = ???? // I don't know the WCF Webservice
    _ns1__GetDataResponse response;
    if(webService.GetData(&request, &response) == SOAP_OK)
    {
        std::cout << "Returned " << response.????;
    }
    

    I don't know the WCF Webservice. But I guess that you have to fill the request instance with some values. What makes me wonder is, that the class names _ns1__GetData and _ns1__GetDataResponse begin with an underscore. I'm using gSoap for a long time and the names were always without beginning underscore.