REST Representational State TransferPresentation OverviewMotivation Behind RESTWhat Is REST?Slide 5Slide 6Slide 7Slide 8Slide 9World Wide Web: A RESTfull DesignSlide 11Slide 12REST vs. RCP ApproachExample of RPC ApplicationExample of REST ApplicationREST vs. Web Services (RPC)REST in More DepthREST is about ArchitectureFirst Definition of RESTREST Architectural CharacteristicsSlide 21REST Operational CharacteristicsSlide 23Full Definition of RESTWhy REST?REST and Web SyndicationAmazon S3Slide 28SummaryQuestions and DiscussionSlide 31Slide 32Slide 33Slide 34Slide 35ReferencesExtrasSlide 38Slide 39Slide 40Slide 41RESTREPRESENTATIONALSTATETRANSFERScott Ainsworth & Louis Nguyen (Group 1)Old Dominion University, CS 791: Web Syndication Formats, January 29, 2008Presentation OverviewMotivation Behind RESTWhat is REST?A Simple ExampleThe Web: a RESTful designREST in more depthREST CharacteristicsWhy REST?REST vs. Web ServicesREST is a Syndication Enabler2Motivation Behind RESTRoy Fielding instrumental in Web architectureWent back for Ph.D.Called it RESTFormally define the Web architecture3What Is REST?A Simple, Concrete ExampleSuppose we have a Web bulletin boardSuppose we need to view, update, and delete messagesSuppose we follow common procedural programming practices4What Is REST?What message actions are required?Create messageView messageView message for updateDelete message5What Is REST?How do these actions map to HTTP and Web pages?Note the dependence on GET. Why is this?6Action HTTP MethodURLCreate MessagePOST http://bbs/msg.php?m=createView Message GET http://bbs/msg.php?m=view&id=12Update MessagePOST http://bbs/msg.php?m=update&Id=12Delete MessageGET http://bbs/msg.php?m=delete&id=12What Is REST?In addition to GET and PUT, HTTP protocol also includes:PUT: create or replace an objectDELETE: delete an object7What Is REST?How do the message actions map in REST?8Action HTTP MethodURLCreate MessagePOST http://bbs/message/newView Message GET http://bbs/message/12Update MessagePUT http://bbs/message/12Delete Message DELETE http://bbs/message/12What Is REST?HTTP methods POST, GET, PUT, and DELETE are often compared with Create, Read, Update, and Delete (CRUD) operations associated with database functions: HTTP CRUDPOST Create, UpdateGET ReadPUT Create, UpdateDELETE DeleteHTTP methods do not always correspond directly with a single database operation.9World Wide Web: A RESTfull DesignThe Web is example of RESTfull design that conforms to REST principles.The Web consist of HTTP, content types (HTML, etc), and DNS.HTML includes JavaScripts and applets to support code on demand (COD), which allows downloading and executing of code locally.COD provides improved extensibility and configurability, and better access to resources 10World Wide Web: A RESTfull DesignHTTP is a communications protocol used as a transport to request and retrieve information on the WebUniform Interface: URIs, methods, status codes, headers, and content typesSafe Methods: GET, HEAD, OPTIONS, and TRACERetrievals should not change the state of the server, ie. No side effectsGET with side effects: useful for delete/insert message from a database (GET /edit.cgi?action=new)Unsafe Methods: POST, PUT, DELETE 11World Wide Web: A RESTfull DesignHTTP based on client-server principle: separation of web server and browserWhen RESTful, HTTP is statelessClient request, and every thing needed to complete the request, can be processed by the any server without knowing previous request Stateless transaction exampleBuyer: Do you have a 1966 Ford Mustang for sale in Norfolk, VA?Ebay Server1: Yes, there’s one in near ODU and one in Ocean View area. Which one are you interested in?Buyer: I’m interested in buying a 1966 Ford Mustang near ODU in Norfolk, VA. Is it still for sale?Ebay Server2: Yes, here you go: ebay.com/odu_mustang12REST vs. RCP ApproachRemote Procedure Call (RPC) application exposed one or more resourcesProvides unique set method invocationResources are hidden and RCP applications must have knowledge of the resources in order to locate and communicate with itREST is more object orientedResources are highly visible and provided by URLClient can interact with resources uniformly and navigate/transverse between URL w/o much knowledge of the resources13Example of RPC ApplicationRPC OperationsgetUser() addUser() removeUser() updateUser()getLocation() addLocation() removeLocation()updateLocation() listUsers() listLocations()findLocation() findUser()RPC Client CodeexampleAppObject = new ExampleApp('example.com:1234')exampleAppObject.removeUser('001')14Example of REST ApplicationREST Define Resourceshttp://example.com/users/http://example.com/users/{user} (1 for each user)http://example.com/findUserFormhttp://example.com/locations/http://example.com/locations/{location} http://example.com/findLocationFormREST Client CodeuserResource =new Resource('http://example.com/users/001')userResource.delete()userResource.findLocationForm()15REST vs. Web Services (RPC)Web Services RESTProtocols SOAP (Simple Object Access Protocol) over HTTP.HTTPRequest MechanismXML over HTTP, usually POSTHTTPActions (verbs) Many different actions, which are hidden within the request body.Standard HTTP methods (GET, PUT, POST, DELETE)Security Additional SOAP-specific security layer.Web server securityWeb Server HTTP and Web server are simple conduits with much of their power and capability are bypassedHTTP and Web server exploited to fullest extent16REST in More DepthArchitecture and Architectural StyleREST CharacteristicsElementsConfigurationsConstraints, Principles, Guidelines17REST is about ArchitectureSoftware architectureAn abstraction of the elements, configurations, constraints, principles, and guidelines that govern a system’s design and evolution.Software architectural styleA set of constraints that restrict a software architecture.18First Definition of RESTA software architectural style for networked application architectures.19REST Architectural CharacteristicsElementsComponents: Perform computation.Take data as input and produce data as output.Examples: Web Servers, Gateways, Proxies, Applications, DBMSes, Web Browsers.Connectorsdefine interactions between components and encapsulate the details of transferring
View Full Document