BACK TO MAIN PAGE

Google Web API Example

This example gSOAP client provides a platform independent and an easy-to-use C and C++ interface to the Google Web API which enables C and C++ applications to run Google search queries, get cached pages, and perform spelling checking.

Step 1: the Main Program

We wrote an example client program with gSOAP: click here to get the source for gSOAP 1.3 and higher or here to get the source for gSOAP 2.1 and higher and select "File - Save As" from your browser's menu.

Step 2: Generate the SOAP Stub Routines with the gSOAP Compiler

Before you can compile and run your  program, you need to generate C/C++ sources using our SOAP stub compiler. The generated sources take care of the SOAP serialization and deserialization of the data required to access the Google API service which makes programming a SOAP C/C++ application a breeze.

The input to our SOAP stub compiler is a specification of the names of the SOAP methods and the data structures given as C/C++ declarations. Click here to get the header file specification based on the Google Web API WSDL. Save this file as googleapi.h.

Use the gSOAP compiler to process the header file:

soapcpp2 -c googleapi.h
Visit the download page to obtain the gSOAP packages with the compiler.

Step 3: Compile Your Client Apps

Compile the sources. For example, in Linux the command to compile is:
gcc -o googleapi googleapi.c soapC.c soapClient.c stdsoap2.c
The files soapC.c and soapClient.c are generated by the soapcpp2 stub and skeleton compiler. File stdsoap2.c contains the gSOAP runtime library.

Step 4: Try it Out

First you need to obtain a Google Web API license key to access the Google Web API services.

Execute the command:
"googleapi XXXXXXXXXX search gSOAP"
This will return the search query on gSOAP, where XXXXXXXXX is your Google API license key.

Execute the command:
"googleapi XXXXXXXXXX cached 'http://www.cs.fsu.edu/~engelen/soap.html'"
This will return the cached gSOAP web site page, where XXXXXXXXX is your Google API license

Execute the command:
"googleapi XXXXXXXXXX spell terible"
This will return the correct spelling of 'terible' which is 'terrible'.