Sunday, 25 August 2013

Soap Vs Rest

SOAP (Simple Object Access Protocol) is a XML based (application to application) request/response message exchanging protocol which is use to call methods on a remote objects using the XML based messages governed by SOAP message format for method invocation. All messages, in/out types, faults as defined in the SOAP xml are actually converted, mapped and invoked to the remote object's method, arguments and responses, and exceptions respectively at the remote side. SOAP messages defines it own data types which are mapped to the corresponding Java Types or SQL type or C Types etc during the actual method invocation. This conversion between xml messages to object's methods and vice versa is a complicated process and practically needs a client and server side SOAP tools. SOAP messages can be transferred through any application level transport protocol like HTTP, FTP, SMTP etc. but HTTP is the most popular one.

REST (Representational State Transfer) is an architectural style which imposes restriction on the client-server design - like stateless communication between client and server, caching at the client server side, uniform methods etc.. REST style advocates to define everything in terms of Resources which has Representaion of its State that can be Read, Write, Updated and Deleted. Resources can be represented in any format but mostly xml or json is used. Unlike SOAP, messages in REST are not mapped to any resource specific method calls but they are just well formed (resource) information which are parsed at server side and processed as per business logic - Parsing can be done by any means like normal String parsing, SAX, DOM, Streaming parsing, JAXB parsing etc. Unlike SOAP, REST does not restrict message format or usage of tools.

Soap (Simple Object Access Protocol) Rest (Representational State Transfer)
Strict messaging format as defined by SOAP Free format. Mostly XML or JSON.
Operation or RPC oriented Resource oriented
Soap Messages are basically remote method calls with arguments and exceptions and return types.
Soap messages, in/out types, faults are actually converted, mapped and invoked to the remote object's method, arguments and responses, and exceptions respectively at the remote side.
Rest Messages are well formed information and are parsed using XML parsers.
Sometimes messages are converted into objects.
Practically heavily dependent on SOAP based tools both at Server and Client side. Dependency on tools are optional
Messages are machine readable. Messages are human readable.
Messages, operations conversions are complex. Lightweight.

No comments:

Post a Comment