Easy learning with example program codes

soap vs rest web services in java

SOAP web services:

SOAP stands for Simple Object Access Protocol. It is used to transfer the data. It is a XML-based messaging-layer protocol. SOAP can be used in combination with a variety of transport protocols like HTTP, SMTP, and JMS etc.

RESTful web services:

REST stands for REpresentational State Transfer. Unlike SOAP it is a web standards based architecture and not protocol. It uses HTTP protocol for data communication. REST provides the facility to represent a resource in various formats like text, JSON and XML.


Direct comparison of SOAP and REST are not possible because the SOAP is a protocol and REST an architectural style. It is not correct to call REST any HTTP API that isn’t SOAP.
Most important difference between SOAP and REST is the way of coupling between client and server.
A SOAP client will be tightly coupled to the server and works like a custom desktop application. This is like a contract between client and server. If either side changes anything then it may break everything. We need constant updates following any change. In SOAP, the client needs previous knowledge on everything he will be using, or it won’t even begin the interaction. A SOAP client cannot be extended by code-on-demand supplied by the server itself.
A REST client 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. We don’t violate the protocol standards by creating extra methods. We leverage on the standard methods and create the actions with them on our media type. This result into less coupling. A client is supposed to enter a REST service with zero knowledge of the API, except for the entry point and the media type. A REST client can be extended by code-on-demand supplied by the server itself.

Copyright © 2018 CodesJava Protection Status SiteMap