IBM i Webservices – REST vs. SOAP

IBM i

Sep 18

Lets start with this 'REST vs SOAP is not the right question to ask you silly billy!'

SOAP is a protocol – REST is an architectural style (a design for network-based software architectures)

REST concepts are referred to as resources. A representation of a resource must be stateless. It is represented via some media type. Some examples of media types include XML, JSON, and RDF. Resources are manipulated by components. Components request and manipulate resources via a standard uniform interface. In the case of HTTP, this interface consists of standard HTTP ops e.g. GET, PUT, POST, DELETE.

I like this analogy of comparing SOAP vs REST – if you are going to mail a message to someone, SOAP would be a Manila Envelope and REST would be a postcard. SOAP is a securely sealed up message with overheads for both the sender and receiver (meaning wrapping it up, opening message, sorting and reading the papers in the envelope). REST is a quick easy to read message that relies on the security of the transport, in this analogy the mailman is HTTPS (SSL). So you can assume the mailman only speaks bong-bongo and cannot read your postcard.

So the biggest advantages for REST over SOAP are:

REST is more dynamic, no need for creating and updating UDDI (UDDI is an XML-based standard for describing, publishing, and finding web services). REST is not restricted to XML format. REST web services can send plain text, JSON, and also XML.

Sending data over the network in Json format is cheaper than sending it in Xml format in terms of payload. JSON is quicker, shorter and easier to read than XML.

SOAP is a protocol. REST is an architectural style.
SOAP stands for Simple Object Access Protocol. REST stands for REpresentational State Transfer.
SOAP (as a protocol) cannot use REST. REST can use SOAP web services because it is a concept and can use any protocol like HTTP, SOAP.
SOAP uses webservice interfaces to expose the business logic. REST uses URI to expose business logic.
SOAP uses strict standards to follow. REST does not and its much more loosey goosey.
SOAP is fatter and therefore requires more bandwidth and resource than REST. REST being skinnier is quicker than SOAP.
SOAP defines its own security. RESTful web services inherits security measures from the underlying transport (ie: HTTPS SSL).
SOAP permits XML data format only. REST permits different data format such as Plain text, HTML, XML, JSON etc.

UPDATE: I found this amusingly crap infographic which sums it up nicely:

Follow

About the Author

IBM i Software Developer, Digital Dad, AS400 Anarchist, RPG Modernizer, Alpha Nerd and Passionate Eater of Cheese and Biscuits. Nick Litten Dot Com is a mixture of blog posts that can be sometimes serious, frequently playful and probably down-right pointless all in the space of a day. Enjoy your stay, feel free to comment and in the words of the most interesting man in the world: Stay thirsty my friend.