Friday, November 1, 2013

REST - a simple approach for network communication

We know about Websites and Web Applications. In day to day uses, we see that most cases, we use Web Applications rather than websites. Now, web comes into different flavours, a perfect browser based GUI application, a powerful back end Web Service or a lightweight alternative REST Service.

Now, you all know about GUI Applications, anything that you see on a web browser like Internet Explorer, Mozilla Firefox, Google Chrome, Opera. When you hit a URL in the address bar, you see a GUI Application with lots of colours, lots of controls, lots of interactions etc.

But, this is not the case for the later two, they just provide the data in text based format like XML, JSON etc. In these cases, the server just knows which data to provide and care less about the presentation of the data.

Hey, wait, what is the necessity of using Web Services and REST, if we already can present the data in the way we want ?
Well, thanks for bringing up this point. Let's take a closer look on this part here. The business problem is already discussed here and a solution approach is also provided to address the business problem.

Well, I understand now, we need Web Service and REST. Now, my question is why REST, if we already have Web Service to answer all the problems ?
Well, you can use either of them.
Now, just to take a confirmation, would you like to have a powerful client application, more network bandwidth, more processing on data ? No, right !

Well, I got it. So, how REST handles all these scenarios ?
Web services use XML, which means a strict API, more verbose. The communication between Server and Client is also a point to consider. Web Services uses SOAP (based on XML) for communication.
Now, in case of REST, it is all based on HTTP. So, the overhead of request and response processing to and from SOAP or XML to or from Request/Response body is not required. Also REST uses JSON as the backbone for data transfer.
This boils down to less processing, less bandwidth and faster data transfer.

Well, now I understand. But you just told that, REST uses JSON, so what about data integrity ?
Well, that's a catch, REST thinks that the client and server knows their responsibility of transferring data. So, you are free to transfer anything you want. On the other hand, Web Services provide a really beautiful way of transferring data in particular format and you can even impose constraints using DTD and XSD if you want. So, data integrity is really a part where Web Services rule over REST.

Hmm... (Aww...) So, if I have a more like of data integrity, I should use Web Services in the cost of performance and bandwidth.
Yes, you are right. If you have a data integrity constraints, you are more likely to bend over Web Services rather REST.

Prev     Next
Palash Kanti Kundu

No comments:

Post a Comment