Franco(Yucong) Martina(Shuying) Alice(Hanjun) C lasse 4ª E Cinese
Google’s Web Service January 4, 2004 Shuying Wang.
-
Upload
emerald-joseph -
Category
Documents
-
view
218 -
download
3
Transcript of Google’s Web Service January 4, 2004 Shuying Wang.
Google’s Web Service
January 4, 2004
Shuying Wang
Overview
• An introduction to Web Service– SOAP & WSDL
• Google’s Web Service Architecture
• Google Web API
• Google Web API application
Web Evolution
XMLXML
ProgrammableProgrammable
WebWeb
Static WebStatic Web
DHTML JSP ASP…
DHTML JSP ASP…
Dynamic WebDynamic Web
HTMLHTML
Technology
Technology
Innovation
Innovation
Web Pages
Web Pages Alternate Web Pages
Alternate Web Pages
Browse Browse the Webthe Web
Program Program the Webthe Web
Web Services
Web Services
What Is A Web Service?
This is the official W3C take on a Web service definition: “A Web service is a software system designed to support interoperable machine-to-machine interaction over a network. It has an interface described in a machine-processable format (specifically WSDL). Other systems interact with the Web service in a manner prescribed by its description using SOAP-messages, typically conveyed using HTTP with an XML serialization in conjunction with other Web-related standards. ”
Architecture of Web Service
Simple Object Access Protocol – SOAP 1.2
• Generic XML-based RPC protocol• Initial specification only covers HTTP-
binding• Use of XML Schema• Multiple protocol bindings available
today(SMTP, FTP, JMS, etc.)• RPC-style and document-style
communication
Example SOAP Message Request
• A standard XML-based format to describe a SOAP request for a Web Service
• Provides all the information required by the Web Service provider to process the request
• General format of a SOAP request:
HTTP Header SOAP Action
<SOAP-ENV:Envelope> <SOAP-ENV:Header> <!-- Soap Header is optional --> </SOAP-ENV:Header> <SOAP-ENV:Body> <!-- Serialized method invocation data --> </SOAP-ENV:Body></SOAP-ENV:Envelope>
Example SOAP Message Reponse
• A standard XML-based format to describe the Response generated by a Web Service
• Contains information that is to be passed back to the client
• General format of a SOAP response:
HTTP Header
<SOAP-ENV:Envelope> <SOAP-ENV:Body> <!-- Serialized Response Data --> </SOAP-ENV:Body></SOAP-ENV:Envelope>
Web Service Definition Language-WSDL(1)
• From the spec: “XML format for describing network services as a set of endpoints operating on messages containing either document-oriented or procedure-oriented information.”
• In another word, WSDL is XML Based Language for describing web services and how to access them
Web Service Definition Language-WSDL(2)
WSDL describes four pieces of critical data:• Interface information describing all publicly
available functions• Data type declarations for all message
requests and responses• Binding information about the transport
protocol• Address information for locating the service
Web Service at Google
• In 2002 Google and Amazon introduced Web services APIs
• SOAP API for accessing Google– Requires registration for a developer’s license
key– Limit of 1000 queries per day– According to license terms only way to access
Google programmatically
Google Web Service Architecture
Google API Language Support
Google.com
Google API
Google API
Google API
Google APIGoogle API
.NET
JavaPerl
c
PHP
Web Service client
Web Service client
Web Service client
Web Service client
Web Service client
SOAP request
SOAP request
SOAP requestSOAP
response
SOAP response
SOAP response
The Google Web APIs Developer’s Kit
• http://www.google.com/apis/download.html– A cross-platform WSDL file– A Java wrapper library– A sample .NET application– Documentation, including JavaDoc and SOAP
XML samples
Google Web API
• Beta version supports 3 types of queries:– doSearch– doGetCachedPage – doSpellingSuggestion.
Understanding the Google API query
• The command in a typical Perl-based Google API applicaton that sends a query to Google looks like:
$results = $google_search->
doGoogleSearch(key, query, start, maxResults, filter, restrict, safeSearch, lr, ie, oe);
A sample
$results = $google_search-> doGoogleSearch(“12BucK13mY5hoE/34KN0cK@ttH3Do0R”, “+music +mp3”,100, 10, “true”, “”, “true”, “”, “utf8”, “utf8”);
Google API response
• Can Do– Site– Daterange– Intitie– Inurl– Allintext– Allinlinks– Filetype– Info– Link– Related– Cache
• Can’t Do– phonebook– rphonebook– bphonebook– stocks
Programming the Google Web API with Java
import com.google.soap.search.*;import java.io.*;public class Googly { private static String googleKey = "insert key here"; public static void main(String[] args) { GoogleSearch s = new GoogleSearch( ); // Create a new GoogleSearch object try { s.setKey(googleKey); s.setQueryString(args[0]); // Google query from the command-line s.setMaxResults(10);
GoogleSearchResult r = s.doSearch( ); // Query Google GoogleSearchResultElement[] re = r.getResultElements( ); // Gather the results for ( int i = 0; i < re.length; i++ ) { // Output System.out.println(re[i].getTitle( )); System.out.println(re[i].getURL( )); System.out.println(re[i].getSnippet( ) + "\n"); } } catch (GoogleSearchFault f) { System.out.println("GoogleSearchFault: " + f.toString( )); } } }
Google API application
Resources
• http://www.w3c.org/• http://www.google.com/apis/• “Guided Google: A Meta Search Engine
and its Implementation using the Google Distributed Web Services” Ding Choon Hoong & Rajkumar Buyya
• “Google HACKS” Tara Calishain & Rael Dornfest