WSDL Web Services Definition Language Von Nikos Vormwald
Übersicht Einleitung (3-4) WSDL Syntax (8) Geschichte von WSDL (5-6) Warum WSDL? (7) WSDL Syntax (8) Übersicht (9-10) Elemente (11-16) Transmission Primitives (17) Protokoll Bindungen (18) SOAP (19-27) HTTP GET/POST (28-33) MIME (34-35) WSDL-Erstellung mit Tool (36-37)
WSDL – Einleitung Was ist WSDL? Was sind Web Services? Sprache zur Definition von Web Services Was sind Web Services? Alles, was mit WSDL darstellbar ist Ein spezieller Web Service in WSDL-Datei beschrieben Web Service vorstellbar als Funktion: Eingabe = Parameter; Ausgabe = Rückgabewert Kommunikation über Internet Bsp.: Temperaturauskunft Web Service Eingabe: Ort; Ausgabe: Temperatur
WSDL – Einleitung Was ist WSDL nicht? Was wird mit WSDL beschrieben? WSDL ist keine Implementierung! Nur Beschreibung/Informationsdatei über Web Services Was wird mit WSDL beschrieben? Was ich an Web Service senden muss Im Bsp.: Ort (als GPS-Koordinaten? Längengrad? Stadtname? Postleitzahl?) Was ich vom Web Service zurück bekomme Im Bsp.: Temperatur (Celcius? Kelvin? Fahrenheit?) Womit ich senden muss Welches Protokoll (SOAP? HTTP GET/POST? MIME?)
WSDL – Geschichte Vorher: SOAP „Lösungen“: Probleme Protokoll zur Übertragung von Nachrichten Problem: Keine Beschreibung wie Nachrichten aussehen müssen „Lösungen“: IBM: NASSL (Network Accessibility Service Specification Language) Struktur: XML; Datentypen: XSD Microsoft: SCL (Services Contract Language) (Frühling 2000) Struktur: XML; Datentypen: XDR (XML Data Reduced) Probleme Beide Beschreibungen nur für ein Protokoll (SOAP) Beide Beschreibungen inkompatibel
WSDL – Geschichte Lösung: WSDL Von IBM, Microsoft und Ariba WSDL 1.1 - März 2001 Struktur: XML; Datentypen: XSD
Warum WSDL? Web Services müssen sich selbst beschreiben Millionen Unabhängige Komponenten im Internet verfügbar Von jeder Plattform aus nutzbar In jeder Entwicklungssprache geschrieben WSDL zur Beschreibung nutzen Web Service ist für Client nutzbar, ohne Wissen über die Implementierung des Web Service Wissen über die Plattform oder Betriebssystem des Web Service Verwendung offener Standards XML, XSD, SOAP, MIME Kann jeder Web Service unabhängig von Plattform und Implementierung
WSDL Syntax Grundlagen: Warum WSDL Syntax lernen? Endpunkte (Ports) die Nachrichten austauschen Unterscheidung zwischen abstrakter Definition einer Nachricht konkretem Weg, wie die Nachricht auf ein Protokoll abgebildet wird Warum WSDL Syntax lernen? In der Praxis wird WSDL Dokument von Tools erstellt Aber: Für Feinanpassungen Kenntnisse erforderlich
WSDL Syntax Elementenübersicht Types <types> Messages <message> Operations <operation> Port types <portType> Bindings <binding> Ports <port> Services <service>
Porttyp-Operation-Message-Typ Struktur
Das Element <types> <schema targetNamespace=“http://example.com/currenttemp.xsd“ xmlns=“http://www.w3.org/2000/10/XMLSchema“> <element name=“CurrentTemperatureRequest“> <complexType> <all> <element name=“cityCode“ type=“string“/> </all> </complexType> </element> <element name=“CurrentTemperature“> <element name=“temp“ type=“float“/> </schema> </types>
Das Element <message> Besteht aus Teilen (Parts) Jeder Part ist ein Typ/Element <message name=“InputMessage“> <part name=“body“ element=“xsd1:CurrentTemperatureRequest“> </message> <message name=“OutputMessage“> <part name=“body“ element=“xsd1:CurrentTemperature“> Bei Message mit mehr als einem Typ: 2 Möglichkeiten Message mit 2 Teilen; jeder Teil ein Typ Dritten Typ definieren (Typ1 und Typ2) und Message mit einem Teil
Die Elemente <portTyp> und <operation> Operation ~ Funktion mit Eingabe, Ausgabe, Ausnahmen Porttyp mit mehreren Operationen <portType name=“CurrentTemperaturePortType“> <operation name=“GetCurrentTemperature“> <input name=“Input“ message=“InputMessage“> <output name=“Output“ message=“OutputMessage“> <fault name=“Fault“ message=“FaultMessage“> </operation> </portType>
Service-Port-Binding-Porttyp Struktur
Das Element <binding> Definiert, wie eine Operation an ein Protokoll gebunden wird <binding name=“CurrentTemperatureSoapBinding“ type=“CurrentTemperaturePortType“> <soap:binding style=“document“ transport=“http://schemas.cmlsoap.org/soap/http“/> <operation name=“GetCurrentTemperature“> <soap:operation soapOperation=“http://example.com/GetCurrentTemperature“/> <input> <soap:body use=“literal“/> </input> <output> </output> </operation> </binding>
Die Elemente <port> und <service> Ein port verknüpft ein binding mit protokollspezifischer Adresse Ein service kann mehrere ports beinhalten, also auf mehreren Protokollen laufen z.Bsp.: PC mit SOAP; WAP-Handy mit HTTP GET/POST <service name=“CurrentTemperatureService“> <port name=“CurrentTemperaturePort“ binding=“CurrentTemperatureSoapBinding“> <soap:adress location=“http://example.com/currenttemp“/> </port> </service>
Transmission Primitives Welche und wieviele Nachrichten eine Operation hat: One-way Operation (~Prozedur ohne Rückgabewert) Input (z. Bsp.: Bestellung) Request/Response Operation (~Funktion Parameter->Rückgabe) Input (Stadtcode) Output (Temperatur) [Fault] Solicit/Response Operation (keine Bindung vorhanden) Output (Bestellungsstatus) Input (Bestätigung) Notification Operation (keine Bindung vorhanden) Output (periodischer Statusreport)
Protokoll Bindungen SAOP HTTP GET/POST MIME soap:binding soap:operation soap:body soap:fault SMTP Beispiel HTTP GET/POST MIME mime:multipartRelated mime:content mime:mimeXml
soap:binding Weißt darauf hin, dass an SOAP gebunden werden soll Gibt an was genutzt werden soll: Transport Mechanismus (HTTP, SMTP, FTP) (benötigt) Encoding style (rpc,document) (Optional; Standard:document) <binding...> <soap:binding style=“rpc | document“ transport=“uri“/> <operation...> </operation> </binding>
soap:operation Gibt an, wie eine Operation an SOAP gebunden wird Enthält: SOAPAction Header (benötigt bei HTTP-Transport) Encoding style (rpc,document) (Optional; zum Überschreiben) <binding...> <operation...> <soap:operation soapAction=“uri“ style=“rpc | document“/> </operation> </binding>
soap:body Enthält: parts gibt an welche Teile der Nachricht in den SOAP-Body eingefügt werden (optional; Standard: Alle) Use, namespace und encodingStyle geben an wie die Teile in den SOAP Body eingefügt werden. <binding...> <operation...> <input...> <soap:body parts=“nmtokens“ use=“encoded | literal“ namespace=“uri“ encodingStyle=“uri“/> </input> </operation> </binding>
Beispielwerte und zugehörige SOAP Nachrichten Für style (in soap:binding): document Für use (in soap:body): literal <binding...> <soap:binding style=“document“> <operation...> <soap:operation...> <input...> <soap:body use=“literal“/> </input> </operation> </binding> <soapenv:Envelope...> <soapenv:Body> <cityCode>PDX</cityCode> </soapenv:Body> </soapenv:Envelope>
Beispielwerte und zugehörige SOAP Nachrichten Für style (in soap:binding): rpc Für use (in soap:body): literal => Name der Operation eingefügt <binding...> <soap:binding style=“rpc“> <operation...> <soap:operation...> <input...> <soap:body use=“literal“/> </input> </operation> </binding> <soapenv:Envelope...> <soapenv:Body> <GetCurrentTemperature> <cityCode>PDX</cityCode> </GetCurrentTemperature> </soapenv:Body> </soapenv:Envelope>
Beispielwerte und zugehörige SOAP Nachrichten Für style (in soap:binding): rpc Für use (in soap:body): encoded => encodingStyle wird zur Abbildung auf SOAP Body benutzt <binding...> <soap:binding style=“rpc“> <operation...> <soap:operation...> <input...> <soap:body use=“encoded“ encodingStyle=“SOAP1.1“ namespace=“http://example.com/ct“.../> </input> </operation> </binding> <soapenv:Envelope...> <soapenv:Body> <m:GetCurrentTemperature xmlns:m=“http://example.com/ct> <m:cityCode>PDX</m:cityCode> </m:GetCurrentTemperature> </soapenv:Body> </soapenv:Envelope> http://schemas.xmlsoap.org/soap/encoding/
soap:fault Bindet Nachrichtenteil an SOAP Fault Details Use, namespace, encodingStyle gleiche Fkt. wie in soap:body Parts entfällt da Fehler Nachrichten nur einen Teil haben <binding...> <operation...> <fault...> <soap:fault use=“encoded | literal“ namespace=“uri“ encodingStyle=“uri“/> </fault> </operation> </binding>
SMTP Beispiel Anmeldung zu einer Mailingliste (One-way Operation) SMTP am besten geeignet, da Protokoll one-way und asynchron HTTP ist two-way und synchron <definitions> <message name=“SubscribeMailingList“> <part name=“email_address“ element=“xsd:string“/> <part name=“name_of_list“ element=“xsd:string“/> </message> <portType name=“SubscribePortType“> <operation name=“SendSubscription“> <input message=“tns:SubscribeMailingList“> </operation> </portType> <binding name=“SubscribeListSoapBinding“ type=“tns:SubscribePortType“> <soap:binding style=“document“ transport=“http://exmaple.com/smtp“/> <input> <soap:body use=“literal“ parts=“email_address name_of_list“/> </input> <service name=“MailingListService“> <port name=“MailingListPort“ binding=“tns:SubscribeListSoapBinding“> <soap:address location=“mailto:subscribe@example.com“/> </port> </definitions> Übergabe-parameter <definitions> <message name=“SubscribeMailingList“> <part name=“email_address“ element=“xsd:string“/> <part name=“name_of_list“ element=“xsd:string“/> </message> <portType name=“SubscribePortType“> <operation name=“SendSubscription“> <input message=“tns:SubscribeMailingList“> </operation> </portType> Funktion
SMTP Beispiel <binding name=“SubscribeListSoapBinding“ type=“tns:SubscribePortType“> <soap:binding style=“document“ transport=“http://exmaple.com/smtp“/> <operation name=“SendSubscription“> <input> <soap:body use=“literal“ parts=“email_address name_of_list“/> </input> </operation> </binding> <service name=“MailingListService“> <port name=“MailingListPort“ binding=“tns:SubscribeListSoapBinding“> <soap:address location=“mailto:subscribe@example.com“/> </port> </definitions> <definitions> <message name=“SubscribeMailingList“> <part name=“email_address“ element=“xsd:string“/> <part name=“name_of_list“ element=“xsd:string“/> </message> <portType name=“SubscribePortType“> <operation name=“SendSubscription“> <input message=“tns:SubscribeMailingList“> </operation> </portType> <binding name=“SubscribeListSoapBinding“ type=“tns:SubscribePortType“> <soap:binding style=“document“ transport=“http://exmaple.com/smtp“/> <input> <soap:body use=“literal“ parts=“email_address name_of_list“/> </input> <service name=“MailingListService“> <port name=“MailingListPort“ binding=“tns:SubscribeListSoapBinding“> <soap:address location=“mailto:subscribe@example.com“/> </port> </definitions>
HTTP GET/POST Bindung 3 verschiedene Arten eine Nachricht an HTTP Adresse zu binden HTTP GET mit URL encoding HTTP GET mit URL replacement HTTP POST Machen Web Service verfügbar für viele Clients Desktop Browser WAP Handy PDA Jede Plattform, die HTTP unterstützt kann Service nutzen
HTTP GET/POST Bindung Beispiel <definitions> <message name=“AddInput“> <part name=“op1“ element=“xsd:int“> <part name=“op2“ element=“xsd:int“> </message> <message name=“AddOutput“> <part name=“result“ element=“xsd:string“/> <portType name=“AddPortType“> <operation name=“Add“> <input message=“AddInput“> <output message=“AddOutput“> </operation> </portType> <binding name=“b3“ type=“AddPortType“> <http:binding verb=“POST“/> <http:operation location=“o1“/> <input> <mime:content type=“application/x-www-form-urlencoded“/> </input> <output> <mime:content type=“text/html“/> </output> </binding> <binding name=“b2“ type=“AddPortType“> <http:binding verb=“GET“/> <http:urlEncoded/> <binding name=“b1“ type=“AddPortType“> <http:operation location=“o1/(op1)/(op2)“/> <http:urlReplacement/> <service name=“AddService“> <port name=“p1“ binding=“tns:b1“> <http:address location=“http://example.com“/> </port> <port name=“p2“ binding=“tns:b2“> <port name=“p3“ binding=“tns:b3“> </service> </definitions> Addition zweier Zahlen Input: int,int; Output: string <definitions> <message name=“AddInput“> <part name=“op1“ element=“xsd:int“> <part name=“op2“ element=“xsd:int“> </message> <message name=“AddOutput“> <part name=“result“ element=“xsd:string“/> <portType name=“AddPortType“> <operation name=“Add“> <input message=“AddInput“> <output message=“AddOutput“> </operation> </portType>
HTTP GET/POST Bindung Beispiel <definitions> <message name=“AddInput“> <part name=“op1“ element=“xsd:int“> <part name=“op2“ element=“xsd:int“> </message> <message name=“AddOutput“> <part name=“result“ element=“xsd:string“/> <portType name=“AddPortType“> <operation name=“Add“> <input message=“AddInput“> <output message=“AddOutput“> </operation> </portType> <binding name=“b3“ type=“AddPortType“> <http:binding verb=“POST“/> <http:operation location=“o1“/> <input> <mime:content type=“application/x-www-form-urlencoded“/> </input> <output> <mime:content type=“text/html“/> </output> </binding> <binding name=“b2“ type=“AddPortType“> <http:binding verb=“GET“/> <http:urlEncoded/> <binding name=“b1“ type=“AddPortType“> <http:operation location=“o1/(op1)/(op2)“/> <http:urlReplacement/> <service name=“AddService“> <port name=“p1“ binding=“tns:b1“> <http:address location=“http://example.com“/> </port> <port name=“p2“ binding=“tns:b2“> <port name=“p3“ binding=“tns:b3“> </service> </definitions> HTTP POST Bindung <binding name=“b3“ type=“AddPortType“> <http:binding verb=“POST“/> <operation name=“Add“> <http:operation location=“o1“/> <input> <mime:content type=“application/x-www-form-urlencoded“/> </input> <output> <mime:content type=“text/html“/> </output> </operation> </binding> Kommt vom port Element am Ende Führt zu Adresse: http://example.com/o1 Parameter in Body des POST: op1=1&op2=2
HTTP GET/POST Bindung Beispiel <definitions> <message name=“AddInput“> <part name=“op1“ element=“xsd:int“> <part name=“op2“ element=“xsd:int“> </message> <message name=“AddOutput“> <part name=“result“ element=“xsd:string“/> <portType name=“AddPortType“> <operation name=“Add“> <input message=“AddInput“> <output message=“AddOutput“> </operation> </portType> <binding name=“b3“ type=“AddPortType“> <http:binding verb=“POST“/> <http:operation location=“o1“/> <input> <mime:content type=“application/x-www-form-urlencoded“/> </input> <output> <mime:content type=“text/html“/> </output> </binding> <binding name=“b2“ type=“AddPortType“> <http:binding verb=“GET“/> <http:urlEncoded/> <binding name=“b1“ type=“AddPortType“> <http:operation location=“o1/(op1)/(op2)“/> <http:urlReplacement/> <service name=“AddService“> <port name=“p1“ binding=“tns:b1“> <http:address location=“http://example.com“/> </port> <port name=“p2“ binding=“tns:b2“> <port name=“p3“ binding=“tns:b3“> </service> </definitions> HTTP GET mit url encoding <binding name=“b2“ type=“AddPortType“> <http:binding verb=“GET“/> <operation name=“Add“> <http:operation location=“o1“/> <input> <http:urlEncoded/> </input> <output> <mime:content type=“text/html“/> </output> </operation> </binding> Führt zu Adresse: http://example.com/o1?op1=2&op2=2 Parameter als query string
HTTP GET/POST Bindung Beispiel <definitions> <message name=“AddInput“> <part name=“op1“ element=“xsd:int“> <part name=“op2“ element=“xsd:int“> </message> <message name=“AddOutput“> <part name=“result“ element=“xsd:string“/> <portType name=“AddPortType“> <operation name=“Add“> <input message=“AddInput“> <output message=“AddOutput“> </operation> </portType> <binding name=“b3“ type=“AddPortType“> <http:binding verb=“POST“/> <http:operation location=“o1“/> <input> <mime:content type=“application/x-www-form-urlencoded“/> </input> <output> <mime:content type=“text/html“/> </output> </binding> <binding name=“b2“ type=“AddPortType“> <http:binding verb=“GET“/> <http:urlEncoded/> <binding name=“b1“ type=“AddPortType“> <http:operation location=“o1/(op1)/(op2)“/> <http:urlReplacement/> <service name=“AddService“> <port name=“p1“ binding=“tns:b1“> <http:address location=“http://example.com“/> </port> <port name=“p2“ binding=“tns:b2“> <port name=“p3“ binding=“tns:b3“> </service> </definitions> HTTP GET mit url replacement <binding name=“b1“ type=“AddPortType“> <http:binding verb=“GET“/> <operation name=“Add“> <http:operation location=“o1/(op1)/(op2)“/> <input> <http:urlReplacement/> </input> <output> <mime:content type=“text/html“/> </output> </operation> </binding> Führt zu Adresse: http://example.com/o1/1/2 Werte der Parameter Teil der Adresse
HTTP GET/POST Bindung Beispiel <definitions> <message name=“AddInput“> <part name=“op1“ element=“xsd:int“> <part name=“op2“ element=“xsd:int“> </message> <message name=“AddOutput“> <part name=“result“ element=“xsd:string“/> <portType name=“AddPortType“> <operation name=“Add“> <input message=“AddInput“> <output message=“AddOutput“> </operation> </portType> <binding name=“b3“ type=“AddPortType“> <http:binding verb=“POST“/> <http:operation location=“o1“/> <input> <mime:content type=“application/x-www-form-urlencoded“/> </input> <output> <mime:content type=“text/html“/> </output> </binding> <binding name=“b2“ type=“AddPortType“> <http:binding verb=“GET“/> <http:urlEncoded/> <binding name=“b1“ type=“AddPortType“> <http:operation location=“o1/(op1)/(op2)“/> <http:urlReplacement/> <service name=“AddService“> <port name=“p1“ binding=“tns:b1“> <http:address location=“http://example.com“/> </port> <port name=“p2“ binding=“tns:b2“> <port name=“p3“ binding=“tns:b3“> </service> </definitions> Alle 3 HTTP Bindungen in einem Service anbieten <service name=“AddService“> <port name=“p1“ binding=“tns:b1“> <http:address location=“http://example.com“/> </port> <port name=“p2“ binding=“tns:b2“> <port name=“p3“ binding=“tns:b3“> </service> </definitions>
MIME Bindung Eingabe: Stadtcode; Ausgabe: Temperatur, HTML-Dokument mit Wochenaussicht <definitions...> <message name=“CurrentTempRequest“> <part name=“cityCode“ element=“xsd:string“/> <message> <message name=“CurrentTempReponse“> <part name=“currentTemp“ element=“xsd:float“> <part name=“forecast“ element=“xsd:string“> </message> <portType name=“TempPort“> <operation name=“GetCurrentTemp“> <input message=“tns:CurrentTempRequest“> <output message=“tns:CurrentTempResponse“> </operation> </portType> <binding name=“CurrentTempSOAP“ type=“tns:TempPort“> <soap:binding style=“document“ transport=“http://schemas.xmlsoap.org/soap/http“/> <input> <soap:body use=“literal“/> </input> <output> <mime:multipartRelated> <mime:part> <soap:body parts=“currentTemp“ use=“literal“> </mime:part> <mime:content part=“forecast“ type=“text/html“> <operation> </binding> </definitions> <definitions...> <message name=“CurrentTempRequest“> <part name=“cityCode“ element=“xsd:string“/> <message> <message name=“CurrentTempReponse“> <part name=“currentTemp“ element=“xsd:float“> <part name=“forecast“ element=“xsd:string“> </message> <portType name=“TempPort“> <operation name=“GetCurrentTemp“> <input message=“tns:CurrentTempRequest“> <output message=“tns:CurrentTempResponse“> </operation> </portType>
mime:multipartRelated und mime:content <binding name=“CurrentTempSOAP“ type=“tns:TempPort“> <soap:binding style=“document“ transport=“http://schemas.xmlsoap.org/soap/http“/> <operation name=“GetCurrentTemp“> <input> <soap:body use=“literal“/> </input> <output> <mime:multipartRelated> <mime:part> <soap:body parts=“currentTemp“ use=“literal“> </mime:part> <mime:content part=“forecast“ type=“text/html“> </mime:multipartRelated> </output></operation></binding> </definitions> <definitions...> <message name=“CurrentTempRequest“> <part name=“cityCode“ element=“xsd:string“/> <message> <message name=“CurrentTempReponse“> <part name=“currentTemp“ element=“xsd:float“> <part name=“forecast“ element=“xsd:string“> </message> <portType name=“TempPort“> <operation name=“GetCurrentTemp“> <input message=“tns:CurrentTempRequest“> <output message=“tns:CurrentTempResponse“> </operation> </portType> <binding name=“CurrentTempSOAP“ type=“tns:TempPort“> <soap:binding style=“document“ transport=“http://schemas.xmlsoap.org/soap/http“/> <input> <soap:body use=“literal“/> </input> <output> <mime:multipartRelated> <mime:part> <soap:body parts=“currentTemp“ use=“literal“> </mime:part> <mime:content part=“forecast“ type=“text/html“> <operation> </binding> </definitions> Bindet verschiedene Nachrichtenteile an verschiedene MIME Typen Repräsentiert einen MIME Typ (text/html, image/gif)
2 Tools Microsoft SOAP Toolkit IBM Web Services Toolkit Für COM (Visual Basic) Objekt -> WSDL IBM Web Services Toolkit Für COM Objekt, Java Class, EJB Jar File -> WSDL
IBM Web Services Toolkit <definitions...> <message name=“InAddRequest“> <part name=“meth1_inType1“ type=“xsd:int“> <part name=“meth1_inType2“ type=“xsd:int“> </message> <message name=“OutAddResponse“> <part name=“meth1_outType“ type=“xsd:int“> <portType name=“MathServer_Service“> <operation name=“Add“> <input message=“InAddRequest“> <output message=“OutAddResponse“> </operation> </portType> <binding...><service...> </definitions> Java Class -> WSDL public class MathServer { public MathServer() { super(); } public int Add(int op1, int op2) { return 0;
Zusammenfassung WSDL stellt einen benötigten Teil eines Web Services zu Verfügung Es muss einen üblichen Weg geben, Web Services zu beschreiben Typen die benutzt werden Protokolle an die sie gebunden werden WSDL baut auf existierenden Standards auf XSD, SOAP, MIME IBM und Microsoft haben WSDL übernommen, andere folgen WSDL füllt die Lücke zwischen SOAP und UDDI