Tuesday, January 26, 2010

RESTful Services

What is REST?
REST defines an architectural style for building services in the “Web” way. It is one of the Buzz word, all together a different thought process!
REST is not tied to any particular technology or platform – it’s just another way to design things to work like the Web. Again this is not something new. REST concept exists for a long time but not utilized to its full power.
 
Definition:
"Representational state transfer (REST) is a style of software architecture for distributed hypermedia systems such as the World Wide Web. The term Representational State Transfer (REST) was introduced and defined in 2000 by Roy Fielding[1][2] in his doctoral dissertation. Fielding is one of the principal authors of the Hypertext Transfer Protocol (HTTP) specification versions 1.0 and 1.1." - From wikipedia.org

Why REST Popular?

Is Web Popular?! ;) Web - WWW, which is omnipresent everywhere now. Almost every one knows about Web. RESTful architecture simply follows the tenets of the web which provides the same reach to people.
I will give you a specific example - Just think of accessing a Service as below:

You can access whatever the book detail of any author you want through HTTP GET itself! No Soap Messages, Proxy etc.

amazon.com/authors/{author}/{book}
Ex: amazon.com/authors/ArunGanesh/VS2010

amazon.com/authors/{author}?book={book}
Ex: amazon.com/authors/ArunGanesh?book=VS2010

Key Items to remember:

1. In Web, every resource being referred by a unique identifier, also known as a universal resource identifier (URI). URL+URN = URI

URI / Segment of a URI map to Application Logic. In the above example you can see that the segment of the URL itself being mapped to an application logic.

2. Utilize HTTP Verbs - HTTP GET, POST, PUT, DELETE etc.

3. Utilize HTTP Headers for representing what content type is required and services is returning. For instance, you can represent things like: languages, authentication, authorization, accepted encoding, char set, content type, length etc...

No comments: