| 1 | == "Representational State Transfer (REST) is a style of architecture for distributed hypermedia systems such as the World Wide Web." (Roy Fielding 2000 ) == |
| 2 | * REST stands for Representational State Transfer. (It is sometimes spelled "ReST".) It relies on a stateless, client-server, cacheable communications protocol -- and in virtually all cases, the HTTP protocol is used. |
| 3 | * REST is an architecture style for designing networked applications. The idea is that, rather than using complex mechanisms such as CORBA, RPC or SOAP to connect between machines, simple HTTP is used to make calls between machines. |
| 4 | * In many ways, the World Wide Web itself, based on HTTP, can be viewed as a REST-based architecture. RESTful applications use HTTP requests to post data (create and/or update), read data (e.g., make queries), and delete data. Thus, REST uses HTTP for all four CRUD (Create/Read/Update/Delete) operations. |
| 5 | * REST is a lightweight alternative to mechanisms like RPC (Remote Procedure Calls) and Web Services (SOAP, WSDL, et al.). Later, we will see how much more simple REST is. |
| 6 | * Despite being simple, REST is fully-featured; there's basically nothing you can do in Web Services that can't be done with a RESTful architecture. REST is not a "standard". There will never be a W3C recommendataion for REST, for example. And while there are REST programming frameworks, working with REST is so simple that you can often "roll your own" with standard library features in languages like Perl, Java, or C#. |
| 7 | |
| 8 | BY DR. M. ELKSTEIN |
| 9 | |
| 10 | === Characteristics : === |
| 11 | * client-server |
| 12 | * stateless (no stored context in server) |
| 13 | * cache (label each response as cacheable /non-cacheable) |
| 14 | * uniform interface (generic interface HTTP, GET, POST, PUT, DELETE to access resources) |
| 15 | * Named resources - using URL |
| 16 | * Interconnected resource representation - the representations of the resources are interconnected using URLs, thereby enabling a client to progress from one state to another. |
| 17 | * Layered components - intermediaries, such as proxy servers, cache servers, gateways, etc, can be inserted between clients and resources to support performance, security, etc. |
| 18 | |
| 19 | === Principles: === |
| 20 | * Identify all of the conceptual entities you wish to expose as Services. |
| 21 | * Create a URL to EACH resource (NOUNS, not VERBS!) : http://localhost:8080/ontocat/rest/gene/name_of_gene NOT http://localhost:8080/ontocat/rest/get?name=... * |
| 22 | * Categorize your resources according to whether users can just receive a representation of the resource, or whether users can modify (add to) the resource. For the former, make those resources accessible using an HTTP GET. For the later, make those resources accessible using HTTP POST, PUT, and/or DELETE. |
| 23 | * All resources accessible via HTTP GET should be side-effect free. That is, the resource should just return a representation of the resource. Invoking the resource should not result in modifying the resource. |
| 24 | * No man/woman is an island. Likewise, no representation should be an island. In other words, '''put hyperlinks within resource representations to enable users to drill down for more information''', and/or to obtain related information. |
| 25 | * Design to reveal data gradually. Don't reveal everything in a single response document. Provide hyperlinks to obtain more details |
| 26 | * Specify the format of response data using a schema (DTD, W3C Schema, RelaxNG, or Schematron - ). For those services that require a POST or PUT to it, also provide a schema to specify the format of the response.8. Describe how your services are to be invoked using either a WSDL document, or simply an HTML document. |
| 27 | * Describe how your services are to be invoked using either a WSDL document, or simply an HTML document. |
| 28 | |
| 29 | === REST Server Responses : === |
| 30 | * often an XML file |
| 31 | * JSON, CSV |
| 32 | === AJAX & REST : === |
| 33 | * In many ways AJAX applications follow the REST design principle. |
| 34 | ** In AJAX, requests are sent to the server using XMLHttpRequest objects. The response is used by the JavaScript code to dynamically change the current page. |
| 35 | * Each XMLHttpRequest can be viewed as a REST service request, sent using GET. And the response is often in JSON. |
| 36 | |
| 37 | |
| 38 | |
| 39 | (http://www.xfront.com/REST-Web-Services.html |
| 40 | http://rest.elkstein.org/2008/02/what-is-rest.html) |