Pages

Wednesday, September 14, 2016

Understanding WSDL

Understanding WSDL
WSDL (web service description language) is an XML family document describing how to interact with the web service described. Web services can be consumed by the code, generated using WSDL definition, that knows precisely how to interact with the web service. In a nutshell WSDL document contains details about data definition, operations, transport protocols and address of the web service.
WSDL document mainly consists of two sections – Abstract definitions and concrete descriptions. The abstract definition details about data definitions, messages and operations. Concrete section describes bindings or data format specification for operations, and the network address of the service host. A WSDL containing only abstract section is called an abstract WSDL and the one that contains bindings and network details as well is called a concrete WSDL. WSDL build during Oracle SOA development will be abstract in nature. The WSDL, obtained from the server, after deployment is concrete in nature.
Figure 1 WSDL Structure

Figure 1 WSDL Structure
Rest of this document discuss different sections of the WSDL in detail with code examples. During this walk through I have snipped code samples from WSDL provided by www.webservicex.com. To access the WSDL please click on below link. globalweather.asmx?wsdl
·       Abstract section
o   types: Types basically defines the data types used in the messages. A WSDL can have multiple types blocs, each of them can have multiple schema blocks (XSDs).
o   message: An abstract typed definition of the data that could be an input to or output from an operation. A WSDL can have multiple message blocks, each block containing one or more parts referring to elements defined in types block.

o   portType: portType defines an abstract set of operations. operation represents a method signature with parameters referring to the messages defined in message section. A WSDL can have multiple portType blocks, with multiple operations.

An operation block can have three types of parameters, input, output and fault. Every operation contains a mandatory input block, an optional output block, and multiple optional fault blocks followed by an existence of output block.
·       Concrete section
o   binding: binding implements portType. binding is a concrete protocol and data format specification for a particular portType. There could be more than one bindings for a given portType depending on the protocol and data format specification.  Below codes snippet shows that the same portType GlobalWeatherSoap (type = GlobalWeatherSoap in wsdl:binding element) has two different bindings one with soap protocol (targetNamespace = http://schemas.xmlsoap.org/wsdl/soap/) protocol and another with soap12 (targetNamespace = http://schemas.xmlsoap.org/wsdl/soap12/) protocol.
o   service: service is a collection of endpoints or ports. port is an end point, which is a combination of binding and a network address.

While invoking a webservice, the input XML data sent by the client is passed and validated against XSD (defined in types block) used for input message parameters in operation. The output XML data generated by the webservice is again parsed and validated against corresponding XSD defined in types block of the WSDL. In all the above XML code snippets each node has a tag that contains prefix, colon and element name. Here the prefix is called namespace qualifier. This qualifier plays a very important role in validating XMLs agains XSDs, and cross referencing the XML documents. We will understand more details about XML namespaces in the next post.

No comments:

Post a Comment