Unformatted text preview:

{small lecturenumber - heblocknumber :} Web Servicesaddtocounter {blocknumber}{1}{small lecturenumber - heblocknumber :} Web Servicesaddtocounter {blocknumber}{1}{small lecturenumber - heblocknumber :} Approaches to Web Servicesaddtocounter {blocknumber}{1}{small lecturenumber - heblocknumber :} Approaches to Web Servicesaddtocounter {blocknumber}{1}{small lecturenumber - heblocknumber :} RESTaddtocounter {blocknumber}{1}{small lecturenumber - heblocknumber :} RESTaddtocounter {blocknumber}{1}{small lecturenumber - heblocknumber :} REST Philosophyaddtocounter {blocknumber}{1}{small lecturenumber - heblocknumber :} REST vs SOAPaddtocounter {blocknumber}{1}{small lecturenumber - heblocknumber :} Using REST with Amazon.comaddtocounter {blocknumber}{1}{small lecturenumber - heblocknumber :} An exampleaddtocounter {blocknumber}{1}{small lecturenumber - heblocknumber :} URI formataddtocounter {blocknumber}{1}{small lecturenumber - heblocknumber :} Using Amazon's Web serviceaddtocounter {blocknumber}{1}{small lecturenumber - heblocknumber :} Making REST requests to Amazonaddtocounter {blocknumber}{1}{small lecturenumber - heblocknumber :} Types of operationsaddtocounter {blocknumber}{1}{small lecturenumber - heblocknumber :} Examplesaddtocounter {blocknumber}{1}{small lecturenumber - heblocknumber :} responseGroupsaddtocounter {blocknumber}{1}{small lecturenumber - heblocknumber :} Troubleshootingaddtocounter {blocknumber}{1}{small lecturenumber - heblocknumber :} Summaryaddtocounter {blocknumber}{1}Distributed Software DevelopmentWeb Services with RESTChris BrooksDepartment of Computer ScienceUniversity of San FranciscoDepartment of Computer Science — University of San Francisco – p.1/??11-0: Web ServicesWhat is a Web Service?In a nutshell, it’s an interface that allows access to aremote resource using standard Web technologies,such as HTTP, XML, URLs, etc.This can be anything from a page fetched via an HTTPGET to an XML document retrieved via SOAP and anSDK.Goals: Make interoperability easier, allow automatedexchange of data.Department of Computer Science — University of San Francisco – p.2/??11-1: Web ServicesAdvantages:Language and platform independentUses existing, scalable technologyUses port 80Department of Computer Science — University of San Francisco – p.3/??11-2: Approaches to Web ServicesExtensions of RPC.The procedural approach to distributed computationwas well-understood in RPC and in OO flavors, suchas CORBA and RMIThis same model was applied to HTTP transfer ofXML-based data.First implementaiton: XML-RPCEasy to use, but limited.XML-RPC led to SOAP.More complex, but representationally richer.Designed to help build custom protocols for dataexchangeStill a procedural paradigm.Department of Computer Science — University of San Francisco – p.4/??11-3: Approaches to Web ServicesData-oriented approachRather than specifying how a client should interact with aservice, we specify a reference to a data object in the formof a URI.Web as a shared information space, rather than as amedium for transporting messages between hosts.This is sometimes known as the REST approach.Argument: the rest of the Web operates according toREST, so Web Services should as well.Department of Computer Science — University of San Francisco – p.5/??11-4: RESTREST stands for Representational State TransferIdea: Applications work with a representation of aresource (i.e. an XML representation of a song)These representations are shared, or transferredbetween components.These representations allow client applications tomanage their state.Data-centric: all services and resources can bereferenced with URIs.Servers respond to a request by providing arepresentation of an object.Department of Computer Science — University of San Francisco – p.6/??11-5: RESTREST is really more of an architectural model than aprotocol.A recipe for building web-scale applicationsIn paractice, it refers to:encoding requests within an URIusing HTTP to deliver themreturning results via XML.Department of Computer Science — University of San Francisco – p.7/??11-6: REST PhilosophyCurrent success stories for the Web are: URLs/URIs,HTTP, XML.A successful Web services architecture will be built onthese.The Web should be seen as a distributed, universallyindexable, shared information source.Department of Computer Science — University of San Francisco – p.8/??11-7: REST vs SOAPREST sees Web problems as ones of accessinginformation.HTTP GETs to the most zealous.Providing URIs to access everything allows one to linkWeb services directly into the rest of the Web. (forexample, a Web service can be referred to in an RDFdocument as an rdf:resource)SOAP and XML-RPC see Web problems as client-serverdistributed applications.Users should be able to send and receive complex dataREST approach may not fit as nicely into apps thatneed to change state on the server.Here’s an interesting project for someone interested insoftware architectures ...Department of Computer Science — University of San Francisco – p.9/??11-8: Using REST with Amazon.comWe’ll use REST for this lab for some practical reasons:Low learning curve compared to SOAPRelatively well-documented.No funky third-party libs needed.At its essence, A RESTful program to interface withAmazon just needs to open and read a URI, then parsethe resulting XML.Department of Computer Science — University of San Francisco – p.10/??11-9: An example#!/usr/bin/pythonimport urllibfrom xml.dom import minidom## a string that holds the base URL and my subscription ID.base=’http://webservices.amazon.com/onca/xml?Service=AWSECommerceService&SubscriptionId=00DZ9HPDQ8Z2R2WPWCG2’## open the URI and fetch the contentsreturnstr = urllib.urlopen(base +’&Operation=ItemSearch&SearchIndex=Books&Keywords=buffy’).read()## returnstr is XML - let’s parse it and find all the titles.xmldoc = minidom.parseString(returnstr)for node in xmldoc.getElementsByTagName(’Title’) :print node.firstChild.dataDepartment of Computer Science — University of San Francisco – p.11/??11-10: URI formatThe 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 theproper base and keys.Department of Computer Science — University of San Francisco – p.12/??11-11: Using Amazon’s Web serviceFirst, register with Amazon to get a


View Full Document

USF CS 682 - Web Services

Documents in this Course
Load more
Download Web Services
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Web Services and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Web Services 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?