Problem to invoke a method of webservice from a C++ SoapClient

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Asha (s_aasha_at_yahoo.com)
Date: 05/19/04

  • Next message: raheel hussain: "Returning a DataSet from Webservices"
    Date: 18 May 2004 21:13:12 -0700
    
    

    Hi,
       I used SoapClient Libray provided by SQLData to invoke a method
    exposed by Webservices of weblogic over HTTP.(using WSDL). I'm not
    successful to complete this. If we use this library, we need only few
    lines of C++ client code to talk with remote webservice. This library
    provides a method called ExecuteMethod() which takes only 4 impt
    parameters, 1)URL of WSDL file of the server, 2)Method to invoke
    3)paramters 4) output. This method would build a soap client request
    and do html encoding and send that to the server, where it is parsed &
    the response would be build as a soap response and send over http.

    This particular method 'ExecuteMethod()' does all the above functions.
    We could see the log message also from the console window. From the
    logging, am able to see that, connection to weblogic is done properly
    and i cud see the soap request, html encoding etc.. but, i'm getting
    problems with the response.

    Let me give you the piece of code
    `````````````````````````````````

    TestSoapClient()
    {
            // initialize input parameters.
            TCHAR * ppParamNames[3]={"bstrParam1", "bstrParam2", NULL};
            TCHAR * ppParamValues[3]={ "My First Param", "My Second Param",
    NULL};

            TCHAR * pNames[1]={NULL};
            TCHAR * pValues[1]={NULL};
            const TCHAR * szResponse = NULL;

            // create a soapagent in debug mode (mode=4)
            SoapAgent *pSoapAgent= MakeSoapAgent(NULL, NULL,4);
    //,"SQLDataSSL.pem");
            if(pSoapAgent==NULL)
                    return -1;
            vector<string>* pOutputValues;
            HRESULT hr;

            if(SUCCEEDED(hr=pSoapAgent->ExecuteMethod(
                    "http://localhost:7001/axis/services/jmxconnector?wsdl", // WSDL
    file
                    "getDomains", // method name to be invoked.
                    pNames, // vector of input parameter names.
                    pValues, // vector of input parameter values.
                    &pOutputValues // pointer to vector of output parameters
            )))
            {

                    // print out results
                    int nSize = pOutputValues->size();
                    for(int i=0; i<nSize; i++)
                            _tprintf("%s\n", (*pOutputValues)[i].c_str());
                    // this get complete response..
                    szResponse = pSoapAgent->GetResponse(NULL, true);
                    _tprintf("Complete Reponse : \n%s\n", szResponse);
                    // this get the envelope
                    szResponse = pSoapAgent->GetResponse("Envelope", false);
                    _tprintf("Response Envelope : \n%s\n", szResponse);

                    // this get the message body
                     szResponse = pSoapAgent->GetResponse("Envelope|Body", false);
                    _tprintf("Response Body : \n%s\n", szResponse);
                    // this get the return variable
                    szResponse = pSoapAgent->GetResponse("Envelope|Body|Method1Response|bstrReturn",
    false);
                    _tprintf("Return Value : \n%s\n", szResponse);

                    // get an attachment if any, use either Content-Id or numerical
    index as the first parameter.
                    // BYTE * pContent = pSoapAgent->GetAttachment("1", nSize);
            }
            else
            {
                    // obtain error string when failed.
                    _tprintf ("***********************************************************\n");
                    _tprintf("Error String %s\n", pSoapAgent->GetErrorString());
            }
            DestroySoapAgent(pSoapAgent);

            return 0;
    }

    Reference:
    ``````````
    1) http://www.sqldata.com/soapclient/soapclient30.htm
        The Soap Client library I use is SoapClient36c.exe.

    2) http://www.soapclient.com/SoapTest.html -

    This is a test html page. If we give the URL for the WSDL, it will
    fetch the methods in the next page and we can provide the values for
    the paramters for the methods to invoke.

    I had a doubt that, since, i have given the url with localhost, how
    would the remote machine identify the server machine. but, its able to
    connect the server. I tested this by stopping the weblogic server. Its
    not able to send the soap request message.

    It would be really helpful, If somebody would provide me a solution.
    If there is any other pointers, pls guide me.

    Thanx,
    Asha


  • Next message: raheel hussain: "Returning a DataSet from Webservices"

    Relevant Pages

    • Re: SOAP::Lite "service" examples
      ... SOAP::Lite service which uses a working, ... server side stuff, wsdl (which I have access to but would need to ... this (stringification?) context. ... Anyway, I will work on making a simplified WSDL and a Server to serve it, ...
      (comp.lang.perl.misc)
    • SOAP Zugriff auf SAP WAS / Xml-Namespace
      ... SAP-WebApplicationService, und dort eine Methode, über SOAP ... der server, von dem ich nach dem abarbeiten von 'Invoke' aus/in meiner ... und ich bekomme hier zwar auch ein objektarray mit zwei elementen ...
      (microsoft.public.de.german.entwickler.dotnet.csharp)
    • Re: SOAP project
      ... and what do I do if they haven't published the WSDL document? ... your job is much easier - you can create a SOAP ... > | the server as standard SOAP messages. ...
      (microsoft.public.dotnet.languages.csharp)
    • Re: Sending raw SOAP Message to specified port
      ... system written in Delphi. ... Client and Server side. ... instead of that they have made an application, which listens for SOAP ... Is there any parameters in WSDL which says to SoapClient ...
      (comp.lang.php)
    • Re: VB.Net Web Services?
      ... get a simple request / response example working on a local IIS server. ... they use as long as they are following the WSDL standards. ... external company and wrap it in a SOAP envelope. ...
      (microsoft.public.dotnet.general)