Chapter 27. Using the Google and Amazon Web APIs


Google and are both early adopters in the emerging field of web services.

Google is a giant web search engine and directory. is a e-commerce web site that began as an online bookstore and has since branched out into numerous products such as software and electronics. Both sites separately offer software developers web services Application Programming Interfaces (APIs) that give you the ability to manage Google searches using Java objects and access Amazon’s comprehensive product catalogs with your Java code.

For us Java developers, web services means making requests and receiving responses using a special XML format. In other words, you make a request using XML elements and attributes in text form, and receive a response in the same format. Web services typically use an XML-based protocol named Simple Object Access Protocol (SOAP) to transfer information.

In a nutshell, SOAP represents the abstraction of an envelope, that in turn contains optional headers and the message body. The message, composed of its outer envelope, as well as the headers and body, is made up of XML elements that are associated with specified namespaces. The technologies this chapter describes use HTTP to carry these XML-based SOAP messages.

I never really understood SOAP messages until I looked at some samples. Example 27-1 is part of a SOAP response to an Amazon Web Services keyword-search request using the query “Lance Armstrong.” ...

Get Java Servlet & JSP Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.