Tuesday, September 7, 2010

REST & SOAP

SOAP

SOAP has been the protocol in use for making the web services. SOAP which stands for the Simple Object Access Protocol was designed to convert the OOP's (Object Oriented programming) Objects to be transformed over network using XML.
So it is a direct logical descend from the OOP world where SOAP are the objects which are passed across between RPC calls.

RPCs are exact match for the Object method calls. They were promoted to allow the transform the OOP design wihtout much change to distributed architecture over network.

However, this exact thinking needs to be avoided in a distributed architecture. People tend to abstract the location aspect of distributed objects. In any distributed architecture the frequent expensive network calls leads to latency and degraded performance.

Hence, the case of making web service using SOAP using the RPC style Vs Document style.

The SOAP with Document style web services do not exposes the several methods with many parameters but single method with large document.
Example-

SOAP RPC wil be like -

CreateOrder(int Order#, String OrderType, String CustomerNAme, Orderline orderline1...

SOAP Document will be like

CreateOrder(Document OrderDocument)

SOAP RPC style makes it very difficult for clients because they have to deal with so many parameters to use and maintain and, their types.
It also makes it difficult for future changes because in case new field is added then the method will change, or change in type of the parameter also causes problems.

SOAP Document style provides the XML format in which client can provide his data. He has to provide just one parameter; the order document.
It also solves the problem of the future by allowing any changes to be made like adding new fields or change in field types inside the document.

SOAP RPC however is much used because of ease of development because of no requirment of thinking or design. One-2-One Mapping with old techniques of Objects in OOP makes it so easy.

The tools also promotes SOAP RPC because of easy automation of converting the methods by straight forward conversion to soap, hence is preffered by developers.

REST

REST has been lately been preffered protocol for making web services. REST is applying the HTTP methods (GET,POST, PUT and DELETE) on the objects and entities as they have been applied to the HTML pages.

HTTP few methods (GET, POST,PUT and DELETE) is the secret of making it so popular and success of the internet by allowing a simple browser to be able to handle HTML pages by just 4 verbs(methods).

It works on the principle-
There are only 4 things which can be done on an entity like say ORDER

GET RDER
POST ORDER - change the order
PUT ORDER - Add an Order
DELETE ORDER - Delete Order

ORDER changes its state based on the method acting on it. And these verb returns the representational state of the entity (as describe by the URI) as HTML resouces like Web pages, images etc.

REST simplicity is its power by allowing just few verbs(manageable by internet agents like browser to process) as aginest SOAP which introduces hundereds of methods thus making so unmanageble and requires manual intervention.

REST usage in architecture is however recent. There are strategies and best practices which needs to be developed to popularize REST and give confidence to people to be able to use REST actually in spirit and not like transformed version of older technologies.

A for the other concerns like security, REST based on HTTP protocol would be implementing security very similar to how WEb pages is implementing it. It depends on the Server implementing the security on access (for GET, POST, PUT and DELETE) on enities.

No comments:

Post a Comment