Section 19.3.  Google

Prev don't be afraid of buying books Next

19.3. Google

The Google Web service allows programmers to treat Google as if it were a massive database of information about the Web. Or to be more precise, they now have access to the real database that underlies the Google search engine. Now, for example, a programmer can write a program that compares the change in popularity of different slang terms from day to day.

Google provides three different operations:

search

performs a traditional Google search

spelling

checks the spelling of a word and returns a suggestion if it is misspelled: Did you mean "handbook"?

cache

returns the version of a page that Google stored the last time its spider crawled the Web

Example 19-4 illustrates the result of a search query for "XML Handbook". The return element is the payload of a SOAP message. It contains the Google search result.

Example 19-4. Google query result
 <?xml version='1.0' encoding='UTF-8'?> <SOAP-ENV:Envelope   xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"   xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"   xmlns:xsd="http://www.w3.org/1999/XMLSchema"> <SOAP-ENV:Body> <ns1:doGoogleSearchResponse   xmlns:ns1="urn:GoogleSearch"   SOAP-ENV:encodingStyle=     "http://schemas.xmlsoap.org/soap/encoding/">   <return xsi:type="ns1:GoogleSearchResult">     <documentFiltering       xsi:type="xsd:boolean">false</documentFiltering>     <estimatedTotalResultsCount       xsi:type="xsd:int">120000</estimatedTotalResultsCount>     <directoryCategories       xmlns:ns2="http://schemas.xmlsoap.org/soap/encoding/"       xsi:type="ns2:Array"       ns2:arrayType="ns1:DirectoryCategory[0]">     </directoryCategories>     <searchTime xsi:type="xsd:double">0.071573</searchTime>     <resultElements       xmlns:ns3="http://schemas.xmlsoap.org/soap/encoding/"       xsi:type="ns3:Array"       ns3:arrayType="ns1:ResultElement[0]">     </resultElements>     <endIndex xsi:type="xsd:int">0</endIndex>     <searchTips xsi:type="xsd:string"></searchTips>     <searchComments xsi:type="xsd:string"></searchComments>     <startIndex xsi:type="xsd:int">0</startIndex>     <estimateIsExact       xsi:type="xsd:boolean">false</estimateIsExact>     <searchQuery       xsi:type="xsd:string">xml handbook</searchQuery>     </return> </ns1:doGoogleSearchResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope> 

Example 19-4 is clearly not the poster child for XML's simplicity and elegance. But computers have an easier time reading it than do humans.

For example, if you examine the document carefully you can see an estimatedTotalResultsCount element containing the number of hits for this query. A program or XPath expression can find it much more easily than you can. Still, the complexity required by SOAP has somewhat tarnished a mostly positive reaction to Google's service.

And yet Google's result format is considered simple for a SOAP service. So why get involved with SOAP's complexity in the first place? We'll explore that question next.

Amazon


XML in Office 2003. Information Sharing with Desktop XML
XML in Office 2003: Information Sharing with Desktop XML
ISBN: 013142193X
EAN: 2147483647
Year: 2003
Pages: 176

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net