REST is called Representational State Transfer. It is a software architecture style. The World Wide Web (www) is the best example of REST.
1. Interfaces are limited to HTTP (REST is as good as stateless HTTP).
- HTTP GET is used for obtaining a representation of a resource.
- HTTP DELETE is used for removing representations of a resource.
- HTTP POST is used for updating or creating the representations of a resource.
- HTTP PUT is used for creating representations of a resource.
2. REST is used to describe interfaces that transmits domain-specific data over HTTP without an additional messaging layer such as SOAP or session tracking via HTTP cookies.
3.a. A resource is any item of interest. e.g. user. Clients may access this resource with this url "http://example.com/users/{user}" (one for each user).
3.b. A representation of the resource is returned. e.g. 001.html. The representation places the client application in a state. The client traverses further and another resource is accessed. The new representation places the client application in yet another state. Thus the client application state is transfered with each resource representation. Therefore Representational State Transfer.
4. REST lays emphasis on the diversity of resources - what we call nouns. The resources could be potentially very large.
5. RPC lays emphasis on the diversity of protocols and specialized operations - what we call verbs.
6. An RPC client application must know about an object's identity and data type to locate it and communicate with it.7. A REST application provides addresses for every useful data object and uses those objects as the targets of operations.
8. SOAP and XML-RPC are both designed to operate from a single URI with methods being invoked from within the request payload.
9. REST uses HTTP as it was designed, if you want to get some data you use a HTTP GET request, if you want to delete a record from a database you use a HTTP DELETE request, etc.
10. RPC says, "define some methods that do something" whereas REST says, "define some resources and they will have these methods".
Advantages of REST
- It uses well documented, well established, well used technology and methodology.
- It's already here today; in fact it's been here for the last 12 years!
- Resource centric rather than method centric.
- Given a URI anyone already knows how to access it.
- It's not another protocol on top of another protocol on top of another protocol on top of...
- The response payload can be of any format (some may call this a disadvantage, however the Web copes with it, it's just a case of defining the application grammar).
- Uses the inherent HTTP security model, certain methods to certain URIs can easily be restricted by firewall configuration, unlike other XML over HTTP messaging formats.
- REST makes sense, use what we already have; it is the next logical extension of the web.
No comments:
Post a Comment