際際滷

際際滷Share a Scribd company logo
Dian Wahyu Aditya [email_address] REST v 2.3
Agenda REST Overview
Core Concept
Web Service Demo Struts2
Spring MVC
Android Client
REST? Representational State Transfer # Defined by Roy T. Fielding in his doctoral dissertation. (Co-founder of Apache HTTP Project) An Architectural Style
REST? Representational State Transfer #Use HTTP, URI, and other web standard correctly Web Used Correctly
REST CORE CONCEPT
REST: Core Concept  Things are Resources Resources  can be items of information (a blog entry) or informational descriptions of real things (a blog author) RESOURCE
REST: Core Concept  Resource Have URIs   Uniform Resource Identi鍖er  are unique ids for resources. RESOURCE U R I
REST: Core Concept  Resources have Representation Representations  can have different formats (HTML, XML, JSON). RESOURCE U R I REPRESENTATION REPRESENTATION
REST: Core Concept  Representations have URLs Uniform Resource Locators  describe how to get to a representation of a resource, they include protocol, hostname, path and extra information. RESOURCE U R I REPRESENTATION REPRESENTATION URL URL URL
REST: Core Concept  Client interact via Verbs RESOURCE U R I REPRESENTATION REPRESENTATION URL URL URL POST GET PUT DELETE
RESTFul Web Service
RESTFul Web Service  Use HTTP Standard Methods Retrieve GET Update PUT Create POST Remove DELETE
RESTFul Web Service  Use Standard Methods / Uniform Interface Safe GET Idempotent PUT Idempotent DELETE
RESTFul Web Service  Use Standard Methods / Uniform Interface Safe method # There are no side-effects # The requested resource stays unmodi鍖ed Idempotent # Issuing the same request multiple times yields the same result
RESTFul Web Service  All About the URIs http://blog.mervpolis.com/roller/dwx http://blog.mervpolis.com/roller/dwx/category/Java http://blog.mervpolis.com/roller/dwx/date/201009 http://blog.mervpolis.com/roller/dwx/entry/hibernate_event_listener Directory Structure-like URIs To the Point Easy to Guess
RESTFul Web Service GET /deleteuser?name=Robert HTTP/1.1 DELETE /user/Robert HTTP/1.1

More Related Content

RESTFul WebApp Concept

  • 1. Dian Wahyu Aditya [email_address] REST v 2.3
  • 7. REST? Representational State Transfer # Defined by Roy T. Fielding in his doctoral dissertation. (Co-founder of Apache HTTP Project) An Architectural Style
  • 8. REST? Representational State Transfer #Use HTTP, URI, and other web standard correctly Web Used Correctly
  • 10. REST: Core Concept Things are Resources Resources can be items of information (a blog entry) or informational descriptions of real things (a blog author) RESOURCE
  • 11. REST: Core Concept Resource Have URIs Uniform Resource Identi鍖er are unique ids for resources. RESOURCE U R I
  • 12. REST: Core Concept Resources have Representation Representations can have different formats (HTML, XML, JSON). RESOURCE U R I REPRESENTATION REPRESENTATION
  • 13. REST: Core Concept Representations have URLs Uniform Resource Locators describe how to get to a representation of a resource, they include protocol, hostname, path and extra information. RESOURCE U R I REPRESENTATION REPRESENTATION URL URL URL
  • 14. REST: Core Concept Client interact via Verbs RESOURCE U R I REPRESENTATION REPRESENTATION URL URL URL POST GET PUT DELETE
  • 16. RESTFul Web Service Use HTTP Standard Methods Retrieve GET Update PUT Create POST Remove DELETE
  • 17. RESTFul Web Service Use Standard Methods / Uniform Interface Safe GET Idempotent PUT Idempotent DELETE
  • 18. RESTFul Web Service Use Standard Methods / Uniform Interface Safe method # There are no side-effects # The requested resource stays unmodi鍖ed Idempotent # Issuing the same request multiple times yields the same result
  • 19. RESTFul Web Service All About the URIs http://blog.mervpolis.com/roller/dwx http://blog.mervpolis.com/roller/dwx/category/Java http://blog.mervpolis.com/roller/dwx/date/201009 http://blog.mervpolis.com/roller/dwx/entry/hibernate_event_listener Directory Structure-like URIs To the Point Easy to Guess
  • 20. RESTFul Web Service GET /deleteuser?name=Robert HTTP/1.1 DELETE /user/Robert HTTP/1.1
  • 21. RESTFul Web Service Uniform Interface
  • 22. RESTFul Web Service Stateless GET /resources/getNextPage? HTTP/1.1 Client Web service <?xml version=1.0 ?> <rsp stat=ok> <resource id=1 /> <resource id=2 /> ... <rsp> PreviousPage++; NextPage= previousPage; return nextPage Stateful design
  • 23. RESTFul Web Service Stateless GET /resources/?page=2 HTTP/1.1 Client Web service <?xml version=1.0 ?> <rsp page=2 nextPage = 3 > <resource id=1 /> <resource id=2 /> ... <rsp> getPage(2); Stateless design
  • 24. RESTFul Web Service Allow Multiple Representation GET /technology Host: www.telegraph.co.uk Accept: text/html ;charset=ISO-8859-1 GET /technology /rss Host: www.telegraph.co.uk Accept: text/xml ;charset=UTF-8 <html> ... </html> <rss version=&quot;2.0&quot;> ... </rss>