Sabtu, 25 Februari 2017

What is WSDL and difference between abstract and concrete WSDL

An official W3C standard, the Web Services Description Language (WSDL) is an XML language for describing web services. WSDL 1.1 (which is still in wide use) has five major elements--types, message, portType, binding, and service.  All these major elements may be defined 0 or more times in a WSDL document, except for <types>, which may be 0 or 1 time. Here's a short description of each:

types: This is where XML types to be used in the WSDL document are defined. Traditionally, this has meant using XML Schema, but newer versions of WSDL also support Relax NG.

message: This is the section where the input or output parts of an operation are defined, i.e. the "parameters" or "return types". It may have multiple child <part> elements, though WS-I forbids the use of more than one part per message in a document literal style service. The <part> itself may have an element (referring to a qualified XML element) or a type (referring to an XML Schema type) attribute.

portType: Here is where the operations that a web service offers are defined in terms of messages (input and output, with faults). Faults (referring to SOAP faults here) are the web service equivalent of the exception in languages like C++ or Java; most SOAP toolkits will translate SOAP faults into exceptions at runtime.

binding: This is the "how" of a service, specifying the binding of the operations defined in the portType(s) to specific protocols, such as SOAP.

service: This is the "where" of the service, specifying the address where a bound operation may be found.

Example of WSDL document:

 <?xml version="1.0" encoding="UTF-8" ?>
<definitions targetNamespace="urn:Emp" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="urn:Emp"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:weo="http://www.example.org">
<types>
<xsd:schema targetNamespace="urn:Emp/types" elementFormDefault="qualified"/>
<xsd:schema>
<xsd:import schemaLocation="../Schema/Emp.xsd" namespace="http://www.example.org"/>
</xsd:schema>
</types>
<portType name="EmpDetailsPort">
<operation name="EmpRequestOperation">
<input message="tns:EmpDetailsPort_EmpRequest"/>
<output message="tns:EmpDetailsPort_EmpResponse"/>
</operation>
</portType>
<message name="EmpDetailsPort_EmpRequest">
<part name="part" element="weo:EmpRequest"/>
</message>
<message name="EmpDetailsPort_EmpResponse">
<part name="part" element="weo:EmpResponse"/>
</message>
<binding name="EmpDetailsPortSOAP11Binding" type="tns:EmpDetailsPort">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="EmpRequestOperation">
<soap:operation style="document" soapAction="urn:Emp/EmpRequestOperation"/>
<input>
<soap:body use="literal" parts="part"/>
</input>
<output>
<soap:body use="literal" parts="part"/>
</output>
</operation>
</binding>
<service name="EmpDetailsPort">
<port name="EmpDetailsPortPort" binding="tns:EmpDetailsPortSOAP11Binding">
<soap:address location="http://www.example.com"/>
</port>
</service>
</definitions>


Abstract and Concrete WSDLs


A WSDL document can be divided into "abstract" and "concrete" portions that by convention often are defined in two or more files (where the concrete file imports the abstract one). The abstract elements are <types>, <message>, and <portType> (or <interface> in 2.0); the concrete ones are <binding> and <service>. Separating these two sections allows for maximal reuse and flexibility in defining services.


Tidak ada komentar:

Posting Komentar