Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Building and using REST information services Rion Dooley Outline • • • • • • • What is REST? Why REST? Designing RESTful services Accessing RESTful services Example Demo Questions What is REST? • Stands for REpresentational State Transfer • Defined by Roy Felding (Day Software, cofounder of Apache Software Foundation) "Representational State Transfer is intended to evoke an image of how a well-designed Web application behaves: a network of web pages (a virtual state-machine), where the user progresses through an application by selecting links (state transitions), resulting in the next page (representing the next state of the application) being transferred to the user and rendered for their use.” – Roy Felding What is REST? • • • • It’s a way of thinking about your enterprise. A concept, not a protocol Applies web architecture to web services. Model each document and process as a resource (noun) with a unique URI • Use standard HTTP actions (verbs) to interact with a resource. What is REST? • GET: Retrieve a resource. No modification should be done. No side effects allowed. • DELETE: Remove a resource • POST: Create or update a resource • PUT: Update a resource Why REST? • • • • • Scalable Human and machine usable Language agnostic Globally accessible resources Intuitively understandable URIs, resources, and actions. Designing RESTful Services • Implementing a style, not a protocol – Resources rather than services – Nouns rather than verbs • Resource oriented design (ROD) • What the enterprise is instead of what the enterprise does. • Don’t reinvent the wheel!! Accessing RESTful Services • REST is meant for interoperability. • Built on same technology as the internet. • Can be consumed in many different ways – – – – Web browser Web services Lightweight clients Command line (curl, wget) • May be used by components of an SOA, but need not be a component in an SOA. Designing RESTful Services • Key Principals – – – – – Everything gets an ID Link resources together Use standard methods Resources have multiple representations Communicate statelessly Example • Simple User VO service – Authenticated – Gives user-specific information about a user’s profile, resources, accounts and jobs. – Output HTML and XML responses Example Everything gets an ID • A Resource has a unique URI. • Sample endpoints may be: - /profiles - /resources/id - /profiles/id - /accounts - /resources - /accounts/id • These are human-friendly for the example, but no real need for them to be so. Example Use standard methods /profiles GET – list all user profiles PUT – unused POST – add a new user profile DELETE – unused /profiles/id GET – get user profile details PUT – update user profile POST – unused DELETE – delete user profile /resources GET – list all resources PUT – unused POST – add resource DELETE – unused /resources/id /accounts /accounts/id GET – get resource details PUT – update resource information POST - unused DELETE – delete resource GET – list all accounts PUT – unused POST – add account DELETE - unused GET – get account details PUT – update account details POST - unused DELETE – delete account Example Representation based on request type • Request for XML output GET /resources/forte HTTP/1.1 Host: example.com Accept: application/xml • Request for HTML output GET /resources/forte HTTP/1.1 Host: example.com Accept: text/html • Could be any format you wish to support. Example Resources link together <resource self='http://example.com/resources/forte’> <name>forte</amount> <hostname>forte.example.com</hostname> <status>up</status> <account ref='http://example.com/accounts/1212’>1212</account> <username ref='http://example.com/profiles/jdoe’>jdoe1</username> </resource> Example • Language and implementation details are up to the developer. • Frameworks and APIs available in most popular languages • REST is an architectural design, not a protocol, so work within your skill zone. DEMO Links • Roy Felding’s dissertation – http://www.ics.uci.edu/~fielding/pubs/dissertati on/top.htm • SOAP vs REST comparison paper – http://www.jopera.org/docs/publications/2008/r estws • Security for REST web services presentation by Mark O’Neill of Vordel – http://www.vordel.com/downloads/rsa_conf_20 06.pdf Links • Popular REST Frameworks in Java – – – – Restlet (http://www.restlet.org) Axis 2.0 (http://ws.apache.org/axis2/0_94/rest-ws.html) Jboss RESTEasy (http://www.jboss.org/resteasy/) Apache CXF (http://cxf.apache.org/) • Popular REST Frameworks in other lang. – Ruby on REST(http://rubyforge.org/projects/rubyrest/) – Rest in Python (http://lukearno.com/projects/rip/) – .NET Links • Familiar RESTful services – – – – TeraGrid Info Services (http://info.teragrid.org/web-apps/html/index/) Amazon Web Services (http://aws.amazon.com/) Yahoo! Web Services (http://developer.yahoo.com/everything.html) Google Web Services (http://code.google.com/apis/ajax/) • Accessing REST services – Python: http://developer.yahoo.com/python/python-rest.html Questions