Complete Guide: WSDL and SOAP
Understand the fundamentals of XML-based web services
What is WSDL?
WSDL (Web Services Description Language) is an XML document that completely describes a web service: its operations, messages, data types and endpoints. It's like a "contract" that defines exactly how to interact with the service.
WSDL Structure
π Main Elements
- Types: Defines data types (XSD)
- Messages: Inputs and outputs
- PortType: Operations interface
- Binding: Protocol and format
- Service: Concrete endpoints
π Relationships
- Types β Messages (uses types)
- Messages β PortType (defines interface)
- PortType β Binding (implements protocol)
- Binding β Service (final endpoint)
Advertisement space
WSDL Example
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://example.com/calculator"
targetNamespace="http://example.com/calculator"
elementFormDefault="qualified">
<types>
<xsd:schema targetNamespace="http://example.com/calculator"
elementFormDefault="qualified">
<xsd:element name="AddRequest">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="a" type="xsd:int"/>
<xsd:element name="b" type="xsd:int"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="AddResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="result" type="xsd:int"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</types>
<message name="AddRequestMessage">
<part name="parameters" element="tns:AddRequest"/>
</message>
<message name="AddResponseMessage">
<part name="parameters" element="tns:AddResponse"/>
</message>
<portType name="CalculatorPortType">
<operation name="Add">
<input message="tns:AddRequestMessage"/>
<output message="tns:AddResponseMessage"/>
</operation>
</portType>
<binding name="CalculatorBinding" type="tns:CalculatorPortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="Add">
<soap:operation soapAction="http://example.com/calculator/Add"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="CalculatorService">
<documentation>Calculator service for basic mathematical operations</documentation>
<port name="CalculatorPort" binding="tns:CalculatorBinding">
<soap:address location="http://example.com/calculator"/>
</port>
</service>
</definitions>
SOAP: The Protocol
SOAP (Simple Object Access Protocol) is the communication protocol that uses XML to exchange structured messages between applications.
SOAP Message Structure
SOAP Request
POST http://example.com/calculator HTTP/1.1
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://example.com/calculator/Add"
Content-Length: [automatically calculated]
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:calc="http://example.com/calculator">
<soap:Header>
<!-- Optional metadata: Headers, authentication, transaction, etc -->
</soap:Header>
<soap:Body>
<calc:AddRequest>
<calc:a>15</calc:a>
<calc:b>25</calc:b>
</calc:AddRequest>
</soap:Body>
</soap:Envelope>
SOAP Response
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:calc="http://example.com/calculator">
<soap:Body>
<calc:AddResponse>
<calc:result>40</calc:result>
</calc:AddResponse>
</soap:Body>
</soap:Envelope>
POST http://example.com/calculator HTTP/1.1
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://example.com/calculator/Add"
Content-Length: [automatically calculated]
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:calc="http://example.com/calculator">
<soap:Header>
<!-- Optional metadata: Headers, authentication, transaction, etc -->
</soap:Header>
<soap:Body>
<calc:AddRequest>
<calc:a>15</calc:a>
<calc:b>25</calc:b>
</calc:AddRequest>
</soap:Body>
</soap:Envelope>
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:calc="http://example.com/calculator">
<soap:Body>
<calc:AddResponse>
<calc:result>40</calc:result>
</calc:AddResponse>
</soap:Body>
</soap:Envelope>
Advertisement space
SOAP vs REST: Detailed Comparison
π’ SOAP
- Protocol: XML over HTTP/HTTPS
- Contract: WSDL mandatory
- Security: WS-Security integrated
- Transactions: Native support
- Overhead: High (verbose XML)
- Use cases: Enterprise systems
π REST
- Protocol: JSON/XML over HTTP
- Contract: OpenAPI optional
- Security: OAuth, JWT
- Transactions: Manual implementation
- Overhead: Low (lightweight JSON)
- Use cases: Modern web APIs
π οΈ Essential Tools
Development
- SoapUI: Testing and debugging
- Postman: Universal client
- Insomnia: Modern client
- XMLSpy: WSDL/XSD editor
Code Generation
- wsimport (Java): JAX-WS
- svcutil (.NET): WCF
- zeep (Python): Dynamic client
- node-soap: Node.js
Validation
- XMLLint: XML validation
- WSDL Analyzer: Online
- Schema Validator: XSD
- SOAP Validator: Messages
π‘ Common Problems and Solutions
π§ Namespace Issues
Problem: Namespace errors are very common in SOAP.
Solution: Always check namespaces in WSDL and use exactly the same ones in the request.
π SSL/TLS Certificates
Problem: Legacy services may use outdated TLS.
Solution: Configure client to accept specific versions or update certificates.
π CORS and Proxy
Problem: Browsers block cross-origin SOAP requests.
Solution: Use a proxy server or configure CORS on the SOAP server.
π¦ External Imports
Problem: WSDL with imports to inaccessible external XSD.
Solution: Download all files locally or use tools that resolve imports automatically.
Advertisement space
π Next Steps
Now that you understand the fundamental concepts, explore:
- Practical consumption examples in different languages
- WSDL Viewer to analyze your own files
- Official documentation of the mentioned tools