Tuesday, September 21, 2010

SOAP vs REST

Comparison between SOAP and REST

FunctionlityRESTSOAP
API Flexibility & SimplicityREST methodology is to write Web services using an interface that is already well known and widely used: the URI.SOAP, on the other hand, requires specific knowledge of a new XML specification, and most developers will need a SOAP toolkit to form requests and parse the results.
Bandwidth UsageIn RESTful interface requests and responses can be short.SOAP requires an XML wrapper around every request and response.
SecurityREST calls also go over HTTP or HTTPS, but with REST the administrator (or firewall) can discern the intent of each message by analyzing the HTTP command used in the request.

No Security related API available, only security related stuff is handling the data over https.
A typical SOAP request, on the other hand, will use POST to communicate with a given service.

Has WS-Security api to extend security and encrypt the flow of data to and from the webservice.
Data TransferData that needs to be secure should never be sent as parameters in URIs. And large amounts of data, like that in detailed purchase orders (POs), can quickly become cumbersome or even out of bounds within a URI.SOAP can transport your all text and BINaries without a glitch.
Type HandlingIncase of HTTP based APIs the return value needs to be de-serialized from XML, and then type-casted. SOAP provides relatively stronger typing since it has a fixed set of supported data types. It therefore guarantees that a return value will be available directly in the corresponding native type in a particular platform.
CachingSince HTTP based / Rest-ful APIs can be consumed using simple GET requests, intermediate proxy servers / reverse-proxies can cache their response very easily.On the other hand, SOAP requests use POST and require a complex XML request to be created which makes response-caching difficult.
TransactionsRest doesn't support trasaction.SOAP and WS-* supports transaction.
MetadataThere is no direct way in REST to generating client from server-side-generated metadata. In SOAP with WSDL we can generate the client proxies.
effort and understanding while HTTP based or REST based APIs require greater implementation effort on the server side.it requires greater implementation effort and understanding on the client side
Handle RequestUses the existing Get and Post to handle client requests.Uses standard WSDL to handle client requests.
Protocol UsedREST works on HTTP/SSL only.SOAP/WSDL is the gateway technology to enable interoperability, works both over HTTP and other protocols.
Communication TypeREST communication style is synchronous.SOAP communication style is, synchronous and asynchronous, bulk transfer and reliable message delivery.
Schema supportChallenging to identify and locate resources.Predefined xml schema definition.
Javascript SupportJavascript or any other technology that understands HTTP can be used to invoke Rest webservice.We cannot invoke soap webservice using javascript.
Parsing of DataClient needs to write some additional code to parse the incoming Java object, since there is no WSDL that can be used to readily parse the incoming object.Parsing of data is handled based on WSDL that is exposed to the client.
Data FlowREST is a free form of data flow.SOAP is a standard data flow, which has a predefined standard that can be used by different languages or different kind of clients.
PerformanceBetter performance when compared to SOAP.SOAP has little less performance than REST since it has to parse XML data. But, it mainly depends on the app server’s speed to parse the data and not solely on technology.
SummaryRest should be used only if the webservice is handling simple input and output like sending user and password to login a user and there is no Java object that has multiple fields.SOAP is used when there are complex objects like payments object to be exposed, because client stubs can be built easily using WSDL and there is no need of human readable documentation.

No comments:

Post a Comment