Download Using REST with Amazon's Web Services: A Distributed Software Development Approach and more Study notes Software Engineering in PDF only on Docsity!
Distributed Software Development Using Amazon’s Web Services with REST^ Chris BrooksDepartment of Computer ScienceUniversity of San Francisco
Department of Computer Science — University of San Francisco – p. 1/
11-2:^ Review: REST^ •^ REST Takes a data-oriented approach to web services^ •^ Rather than specifying how a client should interact with aservice, we specify a reference to a data object in the form of aURI.^ •^ Web as a shared information space, rather than as a mediumfor transporting messages between hosts.^ ◦^ Argument: the rest of the Web operates according to REST,so Web Services should as well.
Department of Computer Science — University of San Francisco – p. 2/
11-4:^ REST^ •^ REST is really more of an architectural model than a protocol.^ ◦^ A recipe for building web-scale applications^ •^ In paractice, it refers to:^ ◦^ encoding requests within an URI^ ◦^ using HTTP to deliver them^ ◦^ returning results via XML.
Department of Computer Science — University of San Francisco – p. 4/
11-5:^ Using REST with Amazon.com^ •^ We’ll begin with Amazon’s REST interface for this lab^ ◦^ Gentle introduction to web services from the client side.^ ◦^ Relatively well-documented.^ ◦^ No funky third-party libs needed.^ •^ At its essence, A RESTful program to interface with Amazonjust needs to open and read a URI, then parse the resultingXML.
Department of Computer Science — University of San Francisco – p. 5/
11-7:^ URI format^ •^ The URI consists of two parts:^ ◦^ A base, which is everything before the ’?’ character.^ ◦^ A set of key/value pairs, which is everything after the ’?’.^ •^ Separated by ’&’^ ◦^ Your program needs to construct a URI using the properbase and keys.
Department of Computer Science — University of San Francisco – p. 7/
11-8:^ Using Amazon’s Web service^ •^ First, register with Amazon to get a SubscriptionId.^ •^ Data available:^ ◦^ Product data^ ◦^ Customer content (lists, reviews)^ ◦^ Product listings, including third-party marketplaces.^ ◦^ Shopping carts^ •^ Some of this is more helpful if you want to set up your owne-Commerce site that uses Amazon’s services.
Department of Computer Science — University of San Francisco – p. 8/
11-10:^ Types of operations^ •^ ItemLookup - get information associated with an ItemId^ •^ ItemSearch - get information associated with a keyword(s)^ •^ SimilarityLookup - finf items similar to a given ItemId^ •^ BrowseNodeLookup - find the ’browseNode’ associated with agiven ItemId^ •^ List Lookup/Search - find wish lists or Listmania lists.^ •^ Shopping Cart operations^ •^ Seller lookup - get seller information for a given seller ID.
Department of Computer Science — University of San Francisco – p. 10/
11-11:^ Amazon’s Data Model^ •^ The data returned by Amazon consists of two parts:^ ◦^ OperationRequest - gives the parameters received byAmazon^ ◦^ Data - gives the result of the query^ •^ The exact structure depends on the request - each responsehas a different element.
Department of Computer Science — University of San Francisco – p. 11/
11-13:^ Examples^ •^ Find books related to ’buffy’^ http://webservices.amazon.com/onca/xml?Service=AWSECommerceService&^ &SubscriptionId=[your
subscription^ ID^ here]
&Operation=ItemSearch&SearchIndex=Books&Keywords=buffy • Find information on a particular Buffy book. http://webservices.amazon.com/onca/xml?Service=AWSECommerceService& &SubscriptionId=[your
subscription^ ID^ here]
&Operation=ItemLookup&ItemId=1569714290 • Find items similar to this Buffy book: http://webservices.amazon.com/onca/xml?Service=AWSECommerceService& &SubscriptionId=[your
subscription^ ID^ here] &Operation=SimilarityLookup&ItemId=
Department of Computer Science — University of San Francisco – p. 13/
11-14:^ responseGroups^ •^ You can also specify what data you would like to get back froma request.^ •^ Small, medium, large^ •^ Specific elements^ •^ To get images:^ http://webservices.amazon.com/onca/xml?Service=AWSECommerceService&^ &SubscriptionId=[your
subscription^ ID^ here]
&Operation=ItemLookup&ItemId=1569714290&ResponseGroup=Images • To get all info: http://webservices.amazon.com/onca/xml?Service=AWSECommerceService& &SubscriptionId=[your
subscription^ ID^ here] &Operation=ItemLookup&ItemId=1569714290&ResponseGroup=Large
Department of Computer Science — University of San Francisco – p. 14/
11-16:^ Troubleshooting^ •^ You are limited to one request per second per IP address.^ •^ If you’re not getting the results you expect, make sure you’respecifying the correct reponse groups.^ •^ Don’t forget your SubscriptionId^ •^ You can test out REST queries in your browser.
Department of Computer Science — University of San Francisco – p. 16/
11-17:^ Summary^ •^ REST is a data-centric way of viewing Web Services^ •^ Every resource or object is represented by a URI.^ •^ Advantages:^ ◦^ Integrates into the rest of the Web^ ◦^ Easy to use^ ◦^ No specialized third-party code needed, except for an XMLparser.^ •^ Disadvantages:^ ◦^ Working with URIs may be unwieldy for complex datastructures.^ ◦^ Most useful for data retrieval applications^ ◦^ Harder to use with applications that require two-wayexchange with a server.
Department of Computer Science — University of San Francisco – p. 17/