WSDL
aus www.iwiki.de, der freien Wissensdatenbank
Webservice Description Language
Ein standardisiertes Format zur Schnittstellenbeschreibung eines Webservice.
Inhaltsverzeichnis |
Aufbau
Ein sog. WSDL-Dokument wird mittels XML in mehrere Bereiche gegliedert:
<definitions>
<types>
<schema>...</schema>
</types>
<message>
<part>...</part>
</message>
<portType>
<operation>
<input>...</input>
<output>...</output>
</operation>
</portType>
<binding>
<operation>
<input>...</input>
<output>...</output>
</operation>
</binding>
<service>
<port>...</port>
</service>
</definitions>
Hierbei ist nochmals zu unterscheiden zwischen dem abstrakten, und dem konkreten Teil.
Der abstrakte Teil (types, messages, portType) beschreibt die verwendeten Datentypen und Operationen des Webservices im Allgemeinen.
Der konkrete Teil (binding, service) hingegen liefert exakte Adressen (URIs) und beschreibt ĂĽber welche Protokolle der Webservice erreichbar ist.
Beispiel
Ein vollständiges WSDL-Dokument könnte folgendermassen aussehen:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://localhost/axis/Calculator.jws"
xmlns:apachesoap="http://xml.apache.org/xml-soap"
xmlns:impl="http://localhost/axis/Calculator.jws"
xmlns:intf="http://localhost/axis/Calculator.jws"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:message name="addRequest">
<wsdl:part name="a" type="xsd:int"/>
<wsdl:part name="b" type="xsd:int"/>
</wsdl:message>
<wsdl:message name="addResponse">
<wsdl:part name="addReturn" type="xsd:int"/>
</wsdl:message>
<wsdl:message name="substractRequest">
<wsdl:part name="a" type="xsd:int"/>
<wsdl:part name="b" type="xsd:int"/>
</wsdl:message>
<wsdl:message name="substractResponse">
<wsdl:part name="substractReturn" type="xsd:int"/>
</wsdl:message>
<wsdl:portType name="Calculator">
<wsdl:operation name="substract" parameterOrder="a b">
<wsdl:input message="impl:substractRequest" name="substractRequest"/>
<wsdl:output message="impl:substractResponse" name="substractResponse"/>
</wsdl:operation>
<wsdl:operation name="add" parameterOrder="a b">
<wsdl:input message="impl:addRequest" name="addRequest"/>
<wsdl:output message="impl:addResponse" name="addResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="CalculatorSoapBinding" type="impl:Calculator">
<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="substract">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="substractRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="http://DefaultNamespace" use="encoded"/>
</wsdl:input>
<wsdl:output name="substractResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="http://localhost/axis/Calculator.jws" use="encoded"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="add">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="addRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="http://DefaultNamespace" use="encoded"/>
</wsdl:input>
<wsdl:output name="addResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
namespace="http://localhost/axis/Calculator.jws" use="encoded"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="CalculatorService">
<wsdl:port binding="impl:CalculatorSoapBinding" name="Calculator">
<wsdlsoap:address location="http://localhost/axis/Calculator.jws"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Hier wird ein Webservice namens “Calculator” beschrieben, welcher zwei Methoden (“add”, “substract”) anbietet. Anhand der message-Elemente ist zu erkennen, dass die Methoden lediglich Integer-Werte entgegennehmen und zurückgeben.
Vorteile
Dank eines WSDL-Dokuments (das in der Regel auch automatisch vom entsprechenden Webservice-Hostsystem generiert wird) kann sowohl ein Entwickler (via Browser), als auch ein Anwendungsprogramm die Möglichkeiten eines Webservice schnell und bequem erfassen. Zudem können anhand dieser Webservice-Beschreibung ebenfalls automatisch generierte Programmteile bzw. Methodenaufrufe dynamisch erzeugt werden. Somit bleiben Anwendungen auch nach dem Ändern von genutzten Webservices lauffähig.
WSDL wird zudem zur Registrierung bei einem UDDI-Verzeichnisdienst genutzt.
