WSDL - SOAP is Called a Communication Protocol
1. What is SOAP?
SOAP stands for Simple Object Access Protocol.
It is a protocol used to exchange structured information between systems over a network.
-
Type: Communication protocol
-
Format: Uses XML to structure messages.
-
Transport: Usually works over HTTP or HTTPS, but can also use SMTP, JMS, etc.
-
Purpose: Allows different applications (built on different platforms or languages) to communicate with each other.
In simple terms:
SOAP = Rules for sending and receiving XML messages between systems.
2. Why SOAP is Called a Communication Protocol
SOAP provides standardized rules for communication between a service provider and a service consumer.
It defines:
-
How to format the request and response messages.
-
How to send messages over the network.
-
How errors are handled.
-
How the client and server interoperate, even if they use different programming languages.
For example:
-
A Java service provider can communicate with a .NET or Python consumer using SOAP because both follow the same protocol rules.
3. SOAP and WSDL Relationship
-
WSDL: Describes what the service does and how to call it.
-
SOAP: Defines how to send the message according to the WSDL.
Example:
-
WSDL defines:
-
Operation:
getBalance(accountID)
-
Input:
accountID
-
Output:
balance
-
-
SOAP defines the XML format for sending the request and receiving the response.
4. SOAP Message Structure
A SOAP message is always an XML document with a fixed structure.
SOAP Request Example
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:acc="http://abcbank.com/account">
<soapenv:Header/>
<soapenv:Body>
<acc:GetBalanceRequest>
<acc:accountID>101</acc:accountID>
</acc:GetBalanceRequest>
</soapenv:Body>
</soapenv:Envelope>
SOAP Response Example
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:acc="http://abcbank.com/account">
<soapenv:Header/>
<soapenv:Body>
<acc:GetBalanceResponse>
<acc:balance>2500.75</acc:balance>
</acc:GetBalanceResponse>
</soapenv:Body>
</soapenv:Envelope>
5. SOAP Message Components
Component | Purpose |
---|---|
Envelope | Root element, defines the start and end of the SOAP message |
Header | Optional, used for metadata like authentication, security, and transactions |
Body | Contains the actual request or response data |
Fault | (Optional) Provides error information if the request fails |
6. How SOAP Works in Web Services
Step 1 — WSDL Defines the Contract
-
The WSDL file tells the consumer:
-
Which operations are available.
-
What SOAP XML format to use.
-
Which endpoint URL to send the request to.
-
Step 2 — SOAP Sends the Request
-
The service consumer generates a SOAP XML request based on WSDL.
-
Sends it to the service provider via HTTP.
Step 3 — SOAP Receives the Response
-
The provider processes the request.
-
Sends a SOAP XML response back to the consumer.
7. Example Workflow
Scenario:
ABC Bank provides a GetBalance
web service.
-
Consumer reads WSDL:
http://abcbank.com/services/account?wsdl
-
Consumer generates SOAP request:
<soap:Body> <GetBalanceRequest> <accountID>101</accountID> </GetBalanceRequest> </soap:Body>
-
Provider responds with SOAP:
<soap:Body> <GetBalanceResponse> <balance>2500.75</balance> </GetBalanceResponse> </soap:Body>
8. SOAP Features
-
Platform-independent → Works across Java, .NET, PHP, Python, etc.
-
Language-neutral → Uses XML, so any programming language can read/write.
-
Protocol-independent → Works over HTTP, HTTPS, SMTP, JMS, etc.
-
Extensible → Supports security, authentication, and transactions.
-
Strict → Strongly typed and follows WSDL definitions exactly.
9. SOAP vs REST (Quick Comparison)
Aspect | SOAP | REST |
---|---|---|
Protocol | Yes (strict rules) | No (style-based) |
Format | XML only | JSON, XML, HTML, etc. |
WSDL Support | Required | Optional (Swagger/OpenAPI) |
Transport | Works over multiple protocols | Mostly HTTP |
Use Case | Enterprise apps, banking, B2B | Web APIs, mobile, lightweight apps |
10. Summary
-
SOAP is a communication protocol for exchanging XML-based messages.
-
It works with WSDL to define the structure of requests and responses.
-
It often integrates with UDDI for service discovery.
-
It ensures platform-independent and language-neutral communication.