Differences Between REST and SOAP

Representational State Transfer Simple Object Access Protocol
Based of JAX-RS Based on JAX-WS
Supports HTTP/HTTPS verbs (GET,POST,PUT,DELETE) Supports HTTP (POST Only) and also SMTP, JMS
Transport mechanism is purely HTTP Transport mechanism is through RPC asynchronous messaging, based on publish/subscribe same as JMS.
Doesn’t support ACID, Transactions Supports ACID, Atomic Transactions with WS-AT
Doesn’t support Messaging Supports Reliable Messaging with WS-RM
Doesn’t support Security, as URI parameters are not secured. Supports enterprise Security with WS-Security. To attach WS-Security SOAP header, implement a javax.xml.ws.handler.soap.SOAPHandler class and set the handler chain for the binding of the service proxy object
Can be tested on the Browser Tested via SOAP UI
Exposes RESOURCES which represent DATA Exposes OPERATIONS which represent LOGIC
Supports multiple data formats (XML,JSON,TEXT,..) Supports only XML
Stateless Communication. This can be tested by stop the server and checking if the interactions are able to survive Or go back and forth the webpage, after restarting the server to see if the previous content loads Stateful Communication. Stop the server and go back and forth the webpage to see if the state exists.
Point to Point Communication over HTTP Loosely coupled distributed messaging via RPC
No Strong Typing required Strong Typing
REST can be consumed by any client, even a web browser with AJAX & JavaScript. SOAP can be consumed only with specific clients who can call its Operations defined in the WSDL/WADL
REST is lightweight SOAP is heavily weighted.
REST doesn’t require any XML processing & parsing. SOAP requires XML processing via xmlns:s=”http://www.w3.org/2001/XMLSchema
REST consumes less bandwidth, doesn’t require a SOAP header for every message. SOAP consumes more bandwidth, it requires a SOAP header for every message/service call.
REST is Safe (All GET operations are safe), but not secured. SOAP are safe and secured.
REST is Synchronous, because HTTP is Synchronous. SOAP is asynchronous, as its based on messaging service.
REST have no Data Contracts. SOAP have Data Contracts for Request and Responses.
REST can’t be governed, meaning that You will not know who (which client) is consuming the services SOAP is governed, as it has the knowledge of the client who is consuming the service through service registry.
REST cannot generate client side details (aka. artifacts) as it doesn’t have a WSDL. SOAP can generate client side artifacts via WSDL/WADL.
Error handling, success and failure is done by tracking HTTP response code. SOAP can use its exception types and codes for Error Handling and success/failure responses.
There are no tokens sent from client to server. SOAP calls are token based. Server acquires token from Client.
All GET operations of REST can be cached. There is no caching in SOAP.
Performance is Better than SOAP here because of Caching. SOAP performance is good
RESTful Web services can be created using Jersey framework, RESTEasy, apache httpclient, java.net package, JAX-RS, Spring 3 MVC Annotations, apache cfx SOAP Web Services can be implemented by defining XSD and then adding dependencies of either apache cfx, JAX-WS, apache axis, WCF (Windows Communication Foundation), Spring WS

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s