Definition
WSDL (Web Services Description Language) is an XML-based language used to describe the functionality offered by a web service. It specifies what the service does, where the service is located, and how to invoke it — including the operations, input and output messages, data types, and communication protocols such as SOAP.
Why WSDL matters
WSDL enables machine-readable service contracts so clients and tools can automatically generate client code, validate messages, and understand how to interact with the service without manual documentation. It is heavily used in SOAP-based integrations.
Main components of a WSDL document
Key sections you’ll typically find in a WSDL file:
- types — XML Schema (XSD) definitions for complex data types.
- message — abstract definitions of the data being exchanged.
- portType — an abstract set of operations (like an interface).
- binding — concrete protocol and data format specifications for the operations (e.g., SOAP over HTTP).
- service — the endpoint address where the service is hosted.
Types of WSDL styles
Common design patterns:
- RPC vs Document — RPC describes operation calls with parameters, while Document describes exchange of XML documents.
- literal vs encoded — how XML messages are serialized. Literal/literal wrapped is preferred for interoperability.
WSDL versions
WSDL 1.1 is the most widely implemented (especially in tooling), whereas WSDL 2.0 introduced some changes and clarifications but saw slower adoption. Many platforms still rely on WSDL 1.1.
Sample WSDL snippet
<definitions name="CalculatorService" targetNamespace="http://example.com/calculator" xmlns:tns="http://example.com/calculator" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/">
<types>
<xsd:schema targetNamespace="http://example.com/calculator">
<xsd:element name="addRequest"></xsd:element>
<xsd:element name="addResponse"></xsd:element>
</xsd:schema>
</types>
<message name="AddRequest"><part name="parameters" element="tns:addRequest"/></message>
<message name="AddResponse"><part name="parameters" element="tns:addResponse"/></message>
<portType name="CalculatorPortType"><operation name="Add"><input message="tns:AddRequest"/><output message="tns:AddResponse"/></operation></portType>
<binding name="CalculatorSoapBinding" type="tns:CalculatorPortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
</binding>
<service name="CalculatorService"><port name="CalculatorPort" binding="tns:CalculatorSoapBinding"><soap:address location="https://api.example.com/calculator"/></port></service>
</definitions>
WSDL in Salesforce context
In Salesforce, WSDL files are used both to expose Apex web services (generate WSDL for an Apex class annotated with @webService) and to consume external SOAP services via WSDL2Apex, which generates Apex classes from a WSDL. Be mindful of WSDL complexity — large or complex schemas may fail WSDL2Apex and require manual wrapping or middleware.
Best practices
- Prefer document/literal style for interoperability.
- Keep schemas modular and reuse XSD imports where possible.
- Provide clear targetNamespace and stable endpoint URLs.
- Limit WSDL size for client code generation tools; consider splitting complex services.
- Use versioning strategies (namespaces, endpoints) to avoid breaking clients.
Understanding WSDL is essential for designing and integrating SOAP-based services, especially in enterprise environments and platforms like Salesforce where WSDL-driven code generation is commonly used.








Leave a Reply