RESTful web services


REST (Representational State Transfer) is a web services architecture. If we take SOAP , it is specification for messages used in WS. But REST is a complete architecture of web services which has all the details how it is done in web service invocation.

W3 rest wiki is a one good place for REST specification.

REST can be used with any protocol (HTTP, FTP, SMTP)

Request messages

Requests are made using URIs and parameters. (In SOAP request are made using XML envelops)
So the request data is less in size compared to SOAP. (Comparing with all the meta data)

protocol :// [HOST] / [Resource root] / [Parameters - optional]
https://www.youtube.com/results?search_query=gangamstyle

Requests can be made with HTTP verbs
  • GET (Read data from WS)
  • HEAD (Return just the meta data of WS)
  • POST (Insert data to WS)
  • PUT (Update data in WS)
  • DELETE (Delete data in WS)
To what verbs to respond is implemented in the WS. (ex: Some WS can be read only)

Although this is the request mechanism how you create the request depends on the progrmming language you use.
Ex: To create requests we can use Apache HTTPClient library, Volley library for Android, OKHttp library for Android, XMLHTTPRequest object for JavaScript etc...

Response messages


Return messages can be in any format. REST can return non text/binary data as well.
  • POX (plain old xml)
  • ATOM
  • RSS
  • JSON (especially in mobile applications)
















Share:

0 comments: