Home | | Web Technology | WSDL(Web Services Description Language)

Chapter: Web Technology : Web Services

WSDL(Web Services Description Language)

Web Services Description Language is the standard format for describing a web service in XML format.

WSDL

 

Web Services Description Language is the standard format for describing a web service in XML format.

 

WSDL definition describes how to access a web service and what operations it will perform.

 

WSDL is often used in combination with SOAP and XML Schema to provide web services over the Internet. A client program connecting to a web service can read the WSDL to determine what functions are available on the server. Then the client can then use SOAP to actually call one of the functions listed in the WSDL.

 

The WSDL Document Structure

 

The main structure of a WSDL document looks like this: <definitions>

 

<types>

definition of types........

</types>

<message>

definition of a message....

</message>

<portType>

<operation>

definition of a operation.......

</operation>

</portType>

<binding>

definition of a binding....

</binding>

<service>

definition of a service....

</service>

 

</definitions>

 

A WSDL document can also contain other elements, like extension elements and a service element that makes it possible to group together the definitions of several web services in one single WSDL document.

 

A WSDL document describes a web service using these major elements:

 

Element                Defines

<types>                The data types used by the web service

<message>           The messages used by the web service

<portType>         The operations performed by the web service

<binding>   The communication protocols used by the web service

 

 

 

A WSDL document can also contain other elements, like extension elements, and a service element that makes it possible to group together the definitions of several web services in one single WSDL document.

 

Note: The second set of lines of the WSDL document is optional

 

First lines of the WSDL document

 

<?xml version=”1.0” encoding=”UTF-8” ?> <definitions name=" " targetNamespace="uri" xmlns:tns=”uri”

 

xmlns=”uri”

xmlns:ns2=”uri”

 

xmlns:xsd=”uri” xmlns:soap=”uri” >

 

Second set of lines of the WSDL document <types>

 

<schema>

 

<import namespace="uri" location="uri"/> <complexType name=” “>

 

<sequence>

<element name=” “ type=” “ />

::

</sequence>

</complexType>

</schema>

</types>

 

The types element defines data type definitions that are relevant for the exchanged messages. The content of types is normally XML schema markup. The data type can be either complex type or simple type.

 

The sequence element is a collection of <element> tags. Each element tag specifies name of the operation (service or method) provided by the web service and its data type of the return value.

 

Third set of lines of the wsdl document <message name=" " >

 

<part name=" " type=" " /> </message>

 

::

 

<message name=" " > <part name=" " type=" " /> </message>

 

The message name attribute provides a unique name among all messages defined within the enclosing WSDL document.

 

 

Messages consist of one or more logical parts. Parts are a flexible mechanism for describing the logical abstract content of a message.

 

Each part is associated with a type attribute. Type attribute value can be either complex type or simple type

 

Fourth set of lines of the wsdl document <portType name=" ">

 

<operation name=" " parameterOrder=“ “> <input message=” “ />

 

<output message=” “ /> </operation>

 

-----------

-----------

-----------

</portType>

 

A portType is a named set of abstract operations and the abstract messages involved. The portType name attribute provides a unique name among all port types defined within

 

in the enclosing WSDL document.

An operation is named via the name attribute.

 

The message attribute of the input and output elements provides a unique name among all input and output elements within the enclosing portType.

 

parameterOrder attribute reflects the order of the parameters in the RPC signature.

 

Fifth set of lines of wsdl document <binding name=" " type=" "> <operation name=" "> <input>

 

<soap:body encodingStyle=”uri “ use=”encoded” namespace=”uri” /> </input>

 

<output>

 

<soap:body encodingStyle=”uri “ use=”encoded” namespace=”uri” /> </output>

 

<soap:operation soapAction=” “ /> </operation>

 

<soap:binding transport=uri” style=”rpc” /> </binding>

 

A binding defines message format and protocol details for operations and messages defined by a particular portType. The name attribute provides a unique name among all bindings defined within in the enclosing WSDL document. A binding references the portType that it binds using the type attribute

 

An operation element within a binding specifies binding information for the operation with the same name within the binding's portType.

 

The content of operation element in a binding is a pair of input and output elements. The soap:body element specifies how the message parts appear inside the SOAP Body element.

 

The required use attribute indicates whether the message parts are encoded using some encoding rules, or whether the parts define the concrete schema of the message. If use is encoded, then each message part references an abstract type using the type attribute. These abstract types are used to produce a concrete message by applying an encoding specified by the encodingStyle attribute.

 

The soap:operation element provides information for the operation

The style attribute indicates whether the operation is RPC-oriented or not.

 

The soapAction attribute specifies the value of the SOAPAction header for this operation.

 

Final lines of wsdl document <service name=" ">

 

<port name=" " binding="internet address "> <soap:address location=” ” />

 

</port>

</service>

</definitions>

 

A service groups a set of related ports together. This provides a name for overall web service. Each port associates a binding with an internet address. This address is specified by including a soap: address element in the content of the port as shown.

 

WSDL Document Example

 

Following is the WSDL file that is provided to demonstrate a simple WSDL program. Assuming the service provides a single publicly available function, called sayHello. This function expects a single string parameter and returns a single string greeting. For example if you pass the parameter world then service function sayHello returns the greeting, "Hello, world!".

 

Content of HelloService.wsdl file

 

First set of lines of WSDl doc

 

<definitions name="HelloService" targetNamespace="uri" xmlns="uri"

 

xmlns:soap="uri"

xmlns:tns="uri"

 

xmlns:xsd="uri">

 

Second set of lines of WSDL doc

<types>

 

<schema>

 

<import namespace="uri" location="uri"/> <complexType name=” “>

 

<sequence>

<element name=” “ type=” “ />

::

</sequence>

</complexType>

 

 

</schema>

</types>

 

Third set of lines of WSDl doc

<message name="SayHelloRequest">

 

<part name="firstName" type="xsd:string"/> </message>

 

<message name="SayHelloResponse"> <part name="greeting" type="xsd:string"/> </mess age>

 

Fourth set of lines of WSDl doc

 

<portType name="Hello_PortType"> <operation name="sayHello">

 

<input message="tns:SayHelloRequest"/> <output message="tns:SayHelloResponse"/> </operation>

 

</portType>

 

Fifth set of lines of WSDl doc

 

<binding name="Hello_Binding" type="tns:Hello_PortType"> <soap:binding style="rpc" transport="uri"/>

 

<operation name="sayHello"> <soap:operation soapAction="sayHello"/> <input>

 

<soap:body encodingStyle="uri" namespace="uri" use="encoded"/>

 

</input>

<output>

 

<soap:body encodingStyle="uri" namespace="uri" use="encoded"/>

 

</output>

</operation>

</binding>

 

The last set of lines of WSDl doc

<service name="Hello_Service">

 

<port binding="tns:Hello_Binding" name="Hello_Port"> <soap:address location="uri">

 

</port>

</service>

</definitions>

 

Analysis of the Example Definition : HelloService

Type : Using built-in data types and they are defined in XMLSchema.

 

Message : 1. sayHelloRequest : firstName parameter 2. sayHelloresponse: greeting return value

 

Port Type: sayHello operation that consists of a request and response service. Binding: Direction to use the SOAP HTTP transport protocol.

 

Service: Service available at the URI

 

Port: Associates the binding with the URI where the running service can be accessed. A detailed description of these elements is given in subsequent sections.



 SOAP

 

SOAP is a simple XML-based protocol that allows applications to exchange information over HTTP.

 


Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail
Web Technology : Web Services : WSDL(Web Services Description Language) |


Privacy Policy, Terms and Conditions, DMCA Policy and Compliant

Copyright © 2018-2024 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.