WSDL — Web Services Description Language for SOAP Contracts
In this tutorial, you will learn about WSDL. We cover key concepts, practical examples, and best practices to help you master this topic.
WSDL (Web Services Description Language) is an XML-based contract language that describes SOAP web services including available operations, message formats, data types, and network endpoints.
What You'll Learn
- WSDL document structure and key elements
- How to read and understand WSDL contracts
- Generating client code from WSDL
Why It Matters
WSDL is the formal contract between service provider and consumer. All SOAP-based integrations depend on accurate WSDL documents.
flowchart TD
A["WSDL Document"] --> B["types\n(Data type definitions)"]
A --> C["message\n(Input/output messages)"]
A --> D["portType\n(Operations available)"]
A --> E["binding\n(Protocol and format)"]
A --> F["service\n(Endpoint URL)"]
style A fill:#dbeafe,stroke:#2563eb
Code Examples
<!-- Simple WSDL for a weather service -->
<?xml version="1.0"?>
<definitions name="WeatherService"
targetNamespace="http://example.com/weather.wsdl"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://example.com/weather.wsdl"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<message name="GetTempRequest">
<part name="zipcode" type="xsd:string"/>
</message>
<message name="GetTempResponse">
<part name="temperature" type="xsd:float"/>
</message>
<portType name="WeatherPortType">
<operation name="GetTemperature">
<input message="tns:GetTempRequest"/>
<output message="tns:GetTempResponse"/>
</operation>
</portType>
<binding name="WeatherBinding" type="tns:WeatherPortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="GetTemperature">
<soap:operation soapAction="GetTemperature"/>
<input><soap:body use="literal"/></input>
<output><soap:body use="literal"/></output>
</operation>
</binding>
<service name="WeatherService">
<port name="WeatherPort" binding="tns:WeatherBinding">
<soap:address location="http://example.com/weather"/>
</port>
</service>
</definitions>
# Generating Python client from WSDL using zeep
from zeep import Client
client = Client('http://example.com/weather.wsdl')
result = client.service.GetTemperature(zipcode='10001')
print(f"Temperature: {result}°F")
Common Mistakes
1. WSDL Without XML Schema Imports
Complex WSDLs import external XSD schemas. Missing imports break the contract.
2. Incorrect Namespace Mappings
The targetNamespace and xmlns prefixes must match across the WSDL.
3. Not Versioning WSDL Files
WSDL changes should be versioned like any API contract.
4. Using rpc/encoded Style
Use document/literal wrapping for modern SOAP services.
5. WSDL with Missing Operations
Every operation must have both input and output messages defined.
Practice Questions
- What does WSDL stand for?
- What are the five main sections of a WSDL document?
- How does a client find the service endpoint URL?
- What is the difference between rpc and document style?
- How do you version a WSDL contract?
Answers:
- Web Services Description Language.
- types, message, portType, binding, service.
- From the
service/port/soap:address locationelement. - rpc style uses procedure call semantics; document style uses XML message exchange.
- Use different namespaces or WSDL file names for different versions.
Challenge: Write a WSDL for a bank account service with operations for checkBalance, deposit, and withdraw. Include appropriate request/response messages and data types.
FAQ
What's Next
Learn about UDDI for service discovery, then explore SOAP Messages in detail.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro