You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@axis.apache.org by Davanum Srinivas <da...@gmail.com> on 2005/03/23 19:23:32 UTC

Google Spelling web service from Python

FYI, with latest CVS, i have been able to call the Google Spelling API
from Python using a SWIG wrapper around Axis C++. Here are the steps:

Step #1: drop the axis.i (enclosed attachment) into ws-axis\c directory.

Step #2: run "swig -D__unix -python -c++ -I. axis.i", this generates
among other things a axis_wrap.cxx file

Step #3: add the file to the AxisClient project, tweak the file a bit
to make sure _DEBUG does not pass on to the Python.h as shown below.
Add the python include and libs (i use Python24 from ActiveState)
#undef _DEBUG
#include <Python.h>
#define _DEBUG

Step #4: copy AxisClient dll to _axis.dll in the same directory as axis.py

Step #5: in this directory run python from the prompt and type in the
python script as follows:

import axis
x=axis.Stub("http://api.google.com/search/beta2",axis.APTHTTP1_1)
y=x.getCall()
y.initialize(axis.CPP_RPC_PROVIDER)
y.setTransportProperty(axis.SOAPACTION_HEADER, "urn:GoogleSearchAction")
y.setSOAPVersion(axis.SOAP_VER_1_1)
y.setOperation("doSpellingSuggestion", "urn:GoogleSearch")
y.addParameter(axis.castToVoid("UtimT5ZQFHJ5o51gv017YJMpiQFn58ex"),
"key", axis.XSD_STRING)
y.addParameter(axis.castToVoid("conection"), "phrase", axis.XSD_STRING)
y.invoke()
y.checkMessage("doSpellingSuggestionResponse", "urn:GoogleSearch")
y.getElementAsString("_return","")

That's it :)

thanks,
dims

-- 
Davanum Srinivas - http://webservices.apache.org/~dims/