REST vs. RPC
- It is useful to consider the difference between REST and RPC, since RPC is the starting point for the middleware systems that we examined at the beginning of the semester
- In RPC systems, the design emphasis is on verbs. What operations can I invoke on the system?
- getUser()
- addUser()
- removeUser()
- updateUser()
- getLocation()
- addLocation()
- removeLocation()
- updateLocation()
- listUsers()
- listLocations()
- findLocation()
- findUser()
- In REST systems, the design emphasis is on nouns, i.e., resources and what their representation is and how they are affected by the standard set of methods
- Thus, you would develop an XML representation for User and Location and then clients and servers would operate on these documents to exchange information via the standard set of methods.
- For example (from Wikipedia):
<user>
<name>Jane User</name>
<gender>female</gender>
<location href="http://www.example.org/locations/us/ny/new_york_city">
New York City, NY, US</location>
</user>
- This document is the representation used for the User resource. If clients need information about this user, then they GET this resource and process the XML document. If they need to change the information, they GET the resource, modify it, and then PUT it back on the server. Note how the reference to the Location resource includes a URI. This is an example of this document format enabling hypermedia traversal. A client could first GET this resource, see the location URI, and then “traverse” to that resource by invoking a GET on it.