Getting Started
2 snippetsBasic WSDL structure
WSDL Document Structure
<?xml version="1.0" encoding="UTF-8"?>
<definitions name="HelloService"
targetNamespace="http://example.com/hello"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://example.com/hello"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!-- Types, Messages, PortType, Binding, Service -->
</definitions>Common Namespaces
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://example.com/service"Types
3 snippetsDefining data types
Simple Type Definition
<types>
<xsd:schema targetNamespace="http://example.com/hello">
<xsd:element name="SayHelloRequest">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="name" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="SayHelloResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="greeting" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</types>Complex Type
<xsd:complexType name="Person">
<xsd:sequence>
<xsd:element name="firstName" type="xsd:string"/>
<xsd:element name="lastName" type="xsd:string"/>
<xsd:element name="age" type="xsd:int"/>
</xsd:sequence>
</xsd:complexType>Array Type
<xsd:complexType name="PersonArray">
<xsd:sequence>
<xsd:element name="person" type="tns:Person"
minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>Messages
3 snippetsDefining message structures
Request/Response Messages
<message name="SayHelloRequest">
<part name="parameters" element="tns:SayHelloRequest"/>
</message>
<message name="SayHelloResponse">
<part name="parameters" element="tns:SayHelloResponse"/>
</message>Fault Message
<message name="ErrorMessage">
<part name="fault" element="tns:Error"/>
</message>Multi-Part Message
<message name="ComplexRequest">
<part name="header" element="tns:Header"/>
<part name="body" element="tns:Body"/>
</message>Tired of looking up syntax?
DocuWriter.ai generates documentation and explains code using AI.
Port Type
3 snippetsDefining operations
Basic Port Type
<portType name="HelloPortType">
<operation name="SayHello">
<input message="tns:SayHelloRequest"/>
<output message="tns:SayHelloResponse"/>
</operation>
</portType>Operation with Fault
<portType name="CalculatorPortType">
<operation name="Divide">
<input message="tns:DivideRequest"/>
<output message="tns:DivideResponse"/>
<fault name="DivideByZeroFault" message="tns:ErrorMessage"/>
</operation>
</portType>One-Way Operation
<portType name="NotificationPortType">
<operation name="Notify">
<input message="tns:NotifyRequest"/>
<!-- No output - one-way operation -->
</operation>
</portType>Binding
3 snippetsProtocol and data format specification
SOAP Binding
<binding name="HelloBinding" type="tns:HelloPortType">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="SayHello">
<soap:operation soapAction="http://example.com/SayHello"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>RPC Style Binding
<binding name="CalculatorBinding" type="tns:CalculatorPortType">
<soap:binding style="rpc"
transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="Add">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"
namespace="http://example.com/calculator"/>
</input>
<output>
<soap:body use="literal"
namespace="http://example.com/calculator"/>
</output>
</operation>
</binding>HTTP Binding
<binding name="HttpGetBinding" type="tns:DataPortType">
<http:binding verb="GET"/>
<operation name="GetData">
<http:operation location="/data"/>
<input>
<http:urlEncoded/>
</input>
<output>
<mime:mimeXml part="body"/>
</output>
</operation>
</binding>Service
2 snippetsDefining service endpoints
Basic Service
<service name="HelloService">
<documentation>Simple Hello World Service</documentation>
<port name="HelloPort" binding="tns:HelloBinding">
<soap:address location="http://example.com/hello"/>
</port>
</service>Multiple Ports
<service name="MultiPortService">
<port name="SoapPort" binding="tns:SoapBinding">
<soap:address location="http://example.com/soap"/>
</port>
<port name="HttpPort" binding="tns:HttpBinding">
<http:address location="http://example.com/http"/>
</port>
</service>Documentation
2 snippetsAdding documentation to WSDL
Service Documentation
<service name="HelloService">
<documentation>
This service provides greeting functionality.
Version: 1.0
</documentation>
<!-- ports -->
</service>Operation Documentation
<portType name="HelloPortType">
<operation name="SayHello">
<documentation>
Returns a greeting message for the given name.
</documentation>
<input message="tns:SayHelloRequest"/>
<output message="tns:SayHelloResponse"/>
</operation>
</portType>Complete Example
1 snippetsFull WSDL service definition
Complete WSDL
<?xml version="1.0" encoding="UTF-8"?>
<definitions name="HelloService"
targetNamespace="http://example.com/hello"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://example.com/hello"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<types>
<xsd:schema targetNamespace="http://example.com/hello">
<xsd:element name="SayHelloRequest">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="name" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="SayHelloResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="greeting" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</types>
<message name="SayHelloRequest">
<part name="parameters" element="tns:SayHelloRequest"/>
</message>
<message name="SayHelloResponse">
<part name="parameters" element="tns:SayHelloResponse"/>
</message>
<portType name="HelloPortType">
<operation name="SayHello">
<input message="tns:SayHelloRequest"/>
<output message="tns:SayHelloResponse"/>
</operation>
</portType>
<binding name="HelloBinding" type="tns:HelloPortType">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="SayHello">
<soap:operation soapAction="http://example.com/SayHello"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="HelloService">
<port name="HelloPort" binding="tns:HelloBinding">
<soap:address location="http://example.com:8080/hello"/>
</port>
</service>
</definitions>