Simple Object Access Protocol (SOAP), is a protocol specification for exchanging structured information in the implementation of Web Services in computer networks. Web service is way of communication between different type of applications. Web services are language independent and platform independent. SOAP relies on Extensible Markup Language(XML) for its message format, and usually relies on other Application Layer protocols, most notably Hypertext Transfer Protocol (HTTP) and Simple Mail Transfer Protocol (SMTP), for message negotiation and transmission. So, it is an XML based protocol which allows communication between different applications through XML messages. It doesn’t permit other data format like HTML, JSON etc. To create SOAP web services, there are JAX-WS API is available in Java. SOAP defines its own WS security.
Things that differentiate SOAP from REST::
SOAP is a protocol whereas REST is a set of architectural principles
- SOAP uses XML as data format while REST can use multiple data formats such as XML, JSON, text etc.
- JAX-WS API provides the implementation of SOAP whereas JAX-RS provides the implementation for REST.
- SOAP exchanges data through HTTP post whereas REST provides a unified interface for all HTTP operations such as put, post, get, delete.
- SOAP provides non-functional requirements out of box too such as WS-security, WS-addressing, WS-policy. REST services developers should develop non-functional requirements.
- SOAP has additional overhead as the envelope contains header, body etc. REST doesn’t have overhead, its just data coming in and going back
- SOAP defines a strict formal contract through WSDL and XSD’s, REST need not have a strict formal contract.
- SOAP defines operations and methods separately while REST just depends on HTTP operations.
- SOAP contains WSDL file which defines a strict contract and contains datatypes and operations, REST WADL has no strict contract and just contains URI and HTTP methods.