[prev in list] [next in list] [prev in thread] [next in thread] 

List:       axis-c-user
Subject:    AXIS C++ with Google
From:       krishna <krishna () lac ! uic ! edu>
Date:       2005-02-26 4:11:18
Message-ID: 421FF6E6.6020608 () lac ! uic ! edu
[Download RAW message or body]

Hi

I am trying to develop a Simple Client for Google Search Service using
AXIS.I have downloaded the Google API and registered with Google.I ran
the following simple program given below but it seems to error out.

Tried using the example in the Google API and it works fine!! which implies
that i am doing something wrong.Cant figure out what.

#include <iostream>
#include "GoogleSearchPort.hpp"

using namespace std;

int main()
{
       try{
       GoogleSearchResult *GSR1; //to store Google Search Result
       GoogleSearchPort GSP1; //Google Search Port
       GSR1=GSP1.doGoogleSearch((axiscpp::xsd__boolean)true,
                               <my API key>,
                               "no",
                               1,
                               "utf",
                               (axiscpp::xsd__boolean)false,
                               "blank",
                               10,
                               "blank",
                               "UIC");

       }catch(GoogleSearchService_AxisClientException e)
       {
               cout<<"\n This is an Exceptioncode :"<<e.getExceptionCode();
               cout<<"\n This is the Exception 
:"<<e.getMessage(e.getExceptionCode());
               cout<<"\n e.what()"<<e.what();
       }

}

I do understand that the order of the parameters is not as per the
google wsdl but it is done this way because the axis client has
generated it in the order above.It will not affect as the names of the
parameters are being sent too as it goes as XML.

The client code which calls the doGoogleSearch function is given
below(generated using WSDL2ws tool in AXIS)

GoogleSearchResult* GoogleSearchPort::doGoogleSearch(xsd__boolean
Value0, xsd__string Value1, xsd__string Value2, xsd__int Value3,
xsd__string Value4, xsd__boolean Value5, xsd__string Value6, xsd__int
Value7, xsd__string Value8, xsd__string Value9)
{
       GoogleSearchResult* pReturn = NULL;
       const char* pcCmplxFaultName;
       try
       {
               if (AXIS_SUCCESS !=
m_pCall->initialize(CPP_RPC_PROVIDER, NORMAL_CHANNEL))
                       return pReturn;
               m_pCall->setTransportProperty(SOAPACTION_HEADER ,
"urn:GoogleSearchAction");
               m_pCall->setSOAPVersion(SOAP_VER_1_1);
               m_pCall->setOperation("doGoogleSearch",
"urn:GoogleSearch");
               applyUserPreferences();
               m_pCall->addParameter((void*)&Value0, "filter",
XSD_BOOLEAN);
               m_pCall->addParameter((void*)&Value1, "key",
XSD_STRING);
               m_pCall->addParameter((void*)&Value2, "restrict",
XSD_STRING);
               m_pCall->addParameter((void*)&Value3, "start",
XSD_INT);
               m_pCall->addParameter((void*)&Value4, "ie",
XSD_STRING);
               m_pCall->addParameter((void*)&Value5, "safeSearch",
XSD_BOOLEAN);
               m_pCall->addParameter((void*)&Value6, "lr",
XSD_STRING);
               m_pCall->addParameter((void*)&Value7, "maxResults",
XSD_INT);
               m_pCall->addParameter((void*)&Value8, "oe",
XSD_STRING);
               m_pCall->addParameter((void*)&Value9, "q", XSD_STRING);
               if (AXIS_SUCCESS == m_pCall->invoke())
               {

The output of the current piece of code is as follows

This is an Exceptioncode :66
This is the Exception :The GoogleSearchService service has thrown an
exception. see details
e.what()

-- 
Krishna
www.uic.edu/~krajag2




[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic