At the Forge - Google Web Services

With a little SOAP, cleanliness is next to Googliness.

Most people, including myself, typically want to query the widest possible number of Web pages with our queries; however, there are times when it is more appropriate to retrieve data only from servers in a particular geography or in a certain language. The fact that Google's API makes this possible and straightforward opens the door for many different interesting applications.

Just as we send a query to Google via SOAP-encoded XML, we receive a result in SOAP-encoded XML. But as SOAP::Lite shielded us from having to write even a tiny bit of XML for the query, we similarly will be insulated when it comes to the response. The $results variable provides a Perl interface to the data that we received in response.

And exactly what data will we receive? To know that, we can look at the WSDL file once again. It indicates (among other things) that we will receive responses as a set of results, each of which looks like this:


<xsd:complexType name="ResultElement">
<xsd:all>
    <xsd:element name="summary" type="xsd:string"/>
    <xsd:element name="URL" type="xsd:string"/>
    <xsd:element name="snippet" type="xsd:string"/>
    <xsd:element name="title" type="xsd:string"/>
    <xsd:element name="cachedSize" type="xsd:string"/>
    <xsd:element name="relatedInformationPresent" type="xsd:boolean"/>
    <xsd:element name="hostName" type="xsd:string"/>
    <xsd:element name="directoryCategory" type="typens:DirectoryCategory"/>
    <xsd:element name="directoryTitle" type="xsd:string"/>
</xsd:all>
</xsd:complexType>

In other words, each search result we receive back from Google (up to a maximum of ten) will provide all of the information we need to create a results page that looks just like Google's. Moreover, we can pick and choose the elements we want to display, showing (for example) only the title and the dmoz directory category and title. Or we can show a short snippet from the searched page. Or all of these. Or none of these.

doGoogleSearch is not the only method described in the WSDL file. There also are other methods, such as working with Google's cached pages and checking the spelling of individual words. When Web services were first unveiled to the public, a common example was that a word processor would now be able to call a remote Web service for spell-checking, rather than coming with a built-in system. That day is still far off in the future, but you can imagine using Google's API for an experimental version of such a service.

Moreover, we can use these outputs as inputs into another Web service call, either locally or remotely. Combining data from multiple sites is an increasingly popular thing to do, especially when combined with Google's maps API. It's amazing to see what can happen when you combine services in this way—something that we will explore in the coming months.

______________________

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Google won't give me the key and code for web page : Google maps

Derry Adams's picture

Google maps are terribly inaccurate.

Google DO NOT provide :
Advanced Geocoding
Option for Large Static Maps

service Level Agreement
Technical Support
Support portal & usage reporting

Google maps for business is a basic mapping service for API and is not always free. The customisation is poor, and the coverage is not great, seldom recognising small towns and only to postcode accuracy as NO geocoding !

If something is good enough, they would not give it away !

i prefer a Viamichelin solution, much more professional

Nick Wood's picture

Just had this back from a business who has moved to Google to ViaMichelin !

Initially Simplytrax used a product I trialed and it stank (2008) and I told them I can only assume that this is a joke.

They have sinced changed provider and told me that Google maps are terrible unlike our new system with benefits from enhanced ViaMichelin technology.
Google maps web service is about the worst mapping I have seen and I have seen most mapping systems. No reputable company would use Google API.

Our new platform uses a viamichelin business web service which far surpasses anything we have seen before.

More coverage, better accuracy and support and a world recognised brand for quality for a price less than I thought ( ViaMichelin were Cheaper than the Google enterprise Ajax API we solution by 25% with straight forward Javascript coding !

Mark Boardman of ViaMichelin business UK stated " We are pleased to have secured this contract to ensure the continued success of SimplyTrax"

Nick

Simply Trax

Google won't give me the key and code for web page

arlequin's picture

Dear Reuven,
Congratulations for your article!

I've registered a Google account this morning but still haven't received an email with the file... Is it normal this way?

I'd like to use your perl script embedded into a web page but I work with PHP. Is there a simple way to put that perl code to work on a web page assuming the parameters came from a form?
I assume PHP 4 manages SOAP, can I work with PHP/SOAP?

Thanks

Gabriel Menini
Linux Registered User #207262

Webinar
One Click, Universal Protection: Implementing Centralized Security Policies on Linux Systems

As Linux continues to play an ever increasing role in corporate data centers and institutions, ensuring the integrity and protection of these systems must be a priority. With 60% of the world's websites and an increasing share of organization's mission-critical workloads running on Linux, failing to stop malware and other advanced threats on Linux can increasingly impact an organization's reputation and bottom line.

Learn More

Sponsored by Bit9

Webinar
Linux Backup and Recovery Webinar

Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.

In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.

Learn More

Sponsored by Storix