REST is based on the concept of URI as a mechanism to uniquely identify resources on Internet. Developers use HTTP protocol to get the representational state of resources deployed on Internet.
How REST can be used?

1. Access and manipulate data objects
REST may be used to access data objects when URI identifies data object(s). Primary key of the data objects are integrated within the URI. Developers are responsible for establishing the URI convention (patterns). For example:
http://mysite.com/customers – reference the list of all customer data objects
http://mysite.com/customer/123 – reference the data object of customer 123
http://mysite.com/customer/123/home-address – reference the home address of customer 123
HTTP verbs GET, POST, PUT and DELETE are used to indicate the action applied to the resource
GET – retrieve data object
POST – add new data object
PUT – update existing data object
DELETE – delete data object

Request parameters are used for passing search criteria. Example:
http://mysite.com/customers?last-name=’Smith’ – may be used to retrieve the list of customers with last name Smith when used with GET

2. Execute programming logic (operations)
REST may be used to execute operations when URI identifies an operation. Request parameters are used to pass operation parameters. Operations should be executed with GET only, since we want to get the result of the operation, which is the representation state of the operation resource. In this respect REST is similar to the dynamic languages like Groovy, Scala, etc. and treats data objects and operations are references.
The result of the operation for given parameters is the representational state of the operation resource. Example:
http://mysite.com/validate-credit-line?fist-name=’John’&last-name=’Smith’ – may be called to ensure that customer John Smith passes certain credit requirement. The result may be Boolean (true/false) or numeric number with the credit score of the customer.

3. Retrieve HTML presentation
REST may be used to retrieve the HTML representation of the resources identified by URI. It also allows overloading of URI by requesting different representational states. For example:
http://mysite.com/customers – used with GET and ‘text/xml’ may return XML encoded list of customer data objects
http://mysite.com/customers – used with GET and ‘text/html’ may return HTML page either showing all customers or allowing the user to search for customers.
Developers may use all verbs: GET, POST, PUT and DELETE for HTML presentations. For example blogging side may allow developers to post, put and delete HTML pages in addition to using GET to retrieve them.

4. REST security
Since REST is always HTTP-based (unlike SOAP) it can take advantage of HTTP security features like basic authentication and digest access authentication. That enables the client application to authenticate once with the server and establish a session, which prevents any further authentications.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s