Introduction

This is a demonstration of accessing the Google SOAP API using Spray.

You will need to register with Google for a key which allows 1000 messages per day. See the Google API page for more information.

Spray is a WebServices toolkit for bb Dolphin Smalltalk by Object-Arts.

Preparation

The Spray Download includes a package named "SW WC Google (Spray)". Installing this package will load a number of classes created from the Google WSDL.

Using an operation - doSpellingSuggestion

The following is example workspace code to access the doSpellingSuggestion operation. You will need to include your key received by registering with Google.

Workspace

client := GoogleAPIService new createClient.
exchange := client send: 'doSpellingSuggestion' with: 'your key' with: 'Smaltalk'.
exchange value. 'Smalltalk'

Using an operation - doGoogleSearch

The following is example workspace code to access the doGoogleSearch operation. Again you will need to include your key received by registering with Google.

This operation has 10 parameters. The example below uses a GoogleAPIService class helper method to construct an array of the 10 parameters for a default simple search.

Workspace

client := GoogleAPIService new createClient.
args := GoogleAPIService simpleSearchArgsFor: 'your key' q: 'Smaltalk'.
exchange := client send: 'doGoogleSearch' withArguments: args.
answer := exchange value. a GoogleSearchResult

If you inspect the answer you will see that it is an instance of the GoogleSearchResult class, which contains an array of instances of the ResultElement class

Spray

Steve Waring 24 Apr 2002