Wednesday, July 27, 2016

REST web services

I think you may have an idea about web services on my previous post about SOAP. In this 
post I'm going to explain about REST.

History of REST

REST was created in 2000 by Roy Thomas Fielding in his PhD dissertation. 

Really what is REST ?

  • REST stands for REpresentational State Transfer
  • REST is an architectural design 
  • It is platform and language independent
  • REST uses HTTP for data transaction
  • REST doesn't contain any inbuilt security, session management and encryption features

REST vs SOAP

Look at the following request by SOAP

POST /InStock HTTP/1.1
Host: www.website.com
Content-Type: application/soap+xml; charset=utf-8
Content-Length: nnn

<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">

<soap:Body xmlns:m="http://www.website.com/user">
  <m:GetUsername>
    <m:userName>Ann</m:userName>
  </m:GetUsername>
</soap:Body>

</soap:Envelope>


Look at the same request by REST

http://www.website.com/user/userName/Ann

Now you can understand how easy that SOAP is.


When to use REST ?

  • Social media servers
  • Mobile services
  • Web chat services
  • Other Social Media platforms

REST in  real life

  • Twitter API
  • Google glass API
  • Flicker 

Advantages of REST

  • Easy to implement and maintain.
  • Data can be manipulated in multiple formats (XML, JSON, XHTML, Plain text).
  • Light weight, fast and low bandwidth is required.
  • High scalability

Disadvantages of REST

  • Only work on top of HTTP protocol.
  • No inbuilt security and authentication mechanism.