Saturday, October 22, 2016

SOAP and REST

SOAP and REST as a web service 

One of my friend asked me a question today "why would anyone choose SOAP(Simple Object Access Protocol) instead REST(Representative State Transfer)"? i thought about it for a minute and honestly answered that i haven't ever come a cross a reason. while i feel unsatisfied about my knowledge on web services i did some homework and here's my summery on rest vs soap 


Overview

REST(Representative State Transfer


REST is web standards based architecture and uses HTTP Protocol for data communication. REST Server simply provides access to resources and REST client accesses and presents the resources. It is more like a browser. It's a generic client that knows how to use a protocol and standardized methods, and an application has to fit inside that. You don't violate the protocol standards by creating extra methods, you leverage on the standard methods and create the actions with them on your media type. If done right, there's less coupling(less degree of inter dependence each other), and changes can be dealt with more gracefully. A client is supposed to enter a REST service with zero knowledge of the API, except for the entry point and the media type.

I think following points will help you out to understand more about REST and how it differs from SOAP

  • REST is protocol independent. actually REST is an architectural style not a protocol, It's not coupled to HTTP. Pretty much like you can follow an ftp link on a website, a REST application can use any protocol for which there is an standardized URI scheme.
  • RESTful Web Services are fast because there is no strict specification like SOAP. It consumes less bandwidth and resource.
  • 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 XMLJSON, 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. GETPUTPOSTDELETE.


SOAP(Simple Access Object protocol)

SOAP is a XML-based protocol for accessing web service.It specifies exactly how to encode an HTTP header and an XML file so that a program in one computer can call a program in another computer and pass along information. SOAP also specifies how the called program can return a response. Despite its frequent pairing with HTTP, SOAP supports other transport protocols as well.

  • SOAP messages are encrypted and digitally signed at the message level, SSL works at the transport level. SSL is prone to hacking because it uses Asymmetric Encryption (public and private keys). SOAP uses Symmetric encryption that is much more difficult to break. SOAP requires XML because it is digitally signed and encrypted.
  • SOAP requires more bandwidth and resource than REST.
  • SOAP is typically much slower than other types of middleware standards, including CORBA. This due to the fact that SOAP uses a verbose XML format. You need to fully understand the performance limitations before building applications around SOAP.
  • SOAP has different levels of support, depending upon the programming language supported. For example, SOAP support within Python and PHP is not as strong as it is within Java and .NET.