When to use RESTful Web Services
A RESTful style is appropriate when
- The web services are completely stateless. Each request from client to server must contain all the information necessary to understand the request, and cannot take advantage of any stored context on the server.
- A caching infrastructure can be leverage for performance. A message sent using RESTful Web Services can be cached in the intermediaries, such as proxy servers, cache servers, gateways, etc, between the client and the Server to give high performance, so next time when the client request for the same data, data stored at the cache should be sent to the client.e.g Google Maps is using RESTful uris to provide cachable map tiles.
- The bandwidth needs to be limited. Since, there is no overhead of headers in the REST messages (unlike SOAP messages), REST messages would not need that high bandwidth as is required in case of SOAP Web Services. So, RESTful Web Services can be very useful for limited-profile devices such as PDAs and mobile phones.
- RESTful Web Services can be consumed very easily by the clients. e.g using AJAX, Clients can consume RESTful Web Services directly on their Web pages with simplicity. Rather than starting from scratch, services can be exposed with XML and consumed by HTML pages without significantly refactoring the existing web site architecture. So, existing developers will be more productive because they are adding to something they are already familiar with, rather than having to start from scratch with new technology.
- I have always found, development with REST is easier and quicker than SOAP. Because, of this most of the vendors are adopting RESTful Web Services e.g Flickr, Google etc.
- RESTful Web Services supports a variety of data formats e.g HTML, XML, plain text, PDF, JPEG, JSON etc. RESTful interfaces can easily support different content-types/mime-types.