30
WEB SERVICE DESCRIPTION LANGUAGE ( WSDL) -SIVA SAGAR TELLA

WEB SERVICE DESCRIPTION LANGUAGE ( WSDL)

Embed Size (px)

DESCRIPTION

WEB SERVICE DESCRIPTION LANGUAGE ( WSDL). -SIVA SAGAR TELLA. Overview. What is WSDL? Why WSDL? Elements of WSDL. Structure of WSDL file. Different Elements of WSDL file. What is WSDL ?. WSDL stands for Web Service Description Language. WSDL is an XML document. - PowerPoint PPT Presentation

Citation preview

WEB SERVICE DESCRIPTION LANGUAGE

( WSDL)

-SIVA SAGAR TELLA

Overview

What is WSDL?Why WSDL?Elements of WSDL.Structure of WSDL file.Different Elements of WSDL file.

What is WSDL ?

WSDL stands for Web Service Description Language.

WSDL is an XML document. WSDL is used to describe Web services. WSDL is also used to locate Web

services.

Why WSDL?

Many Organizations provide web services over the network.

For a client to use a particular web service he has to know the format of the request to be sent and the format of the response that is returned.

Client can also know the address of the web service using WSDL.

WSDL is an XML format for describing network services as a set of endpoints operating on messages containing either document-oriented or procedure-oriented information.

The operations and messages are described abstractly, and then bound to a concrete network protocol and message format to define an endpoint.

Elements of WSDL File

<definitions> <types> definition of types </types> <message>definition of message </message> <portType> definition of a port </portType> <binding> definition of a binding </binding> <service> definition of a service </service> </definitions>

Structure of WSDL file

The WSDL document can be divided into two groups of sections.

1) Abstract Definition. Platform and language independent elements are

specified.

2) Concrete Descriptions. Platform and language dependent elements are

specified Abstract Definition group contains <types>, <messages> and

<portType> elements. Concrete Description group contains <binding> and <service> elements.

Client Invoking a Web Service

With WSDL Terminology

<definitions> Element

Root element of the WSDL document.Contains all other elements definitions in

the documents. Sets the name of the WSDL document

and declares the namespaces used in the document.

Outline of <definitions> Element

<definitions name="DefinitionsName" targetNamespace="NamespaceURI" xmlns:prefix="NamespaceURI" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd=“http://www.w3.org/2001/XMLSchema”

xmlns="http://schemas.xmlsoap.org/wsdl/">

<!-- Content of the WSDL file -->

</definitions>

Attributes of <definitions> Element

targetNamespace : Specifies the name for the WSDL

definition as a whole. All the elements in the definitions element

declare their names in the targetNamespace Xmlns : (Used to denote the default namespace)

states that attribute names without a namespace qualification are in the WSDL namespace.

Default Namespace is “http://schemas.xmlsoap.org/wsdl” Xmlns:prefix : states the names beginning with the prefix “prefix” belongs

to the namespace specified by this value.

<types> Element

Contains schema definitions of the data types used in the messages that compose the service.

WSDL uses XML Schema syntax to define data types.

This element is optional if the service uses the primitive data types defined by XML Schema.

Example

<types> <xsd:schema targetNamespace=

"http://www.roguewave.com/webservices/examples/WeatherSummary.xsd" <xsd:complexType name="WeatherSummary"> <xsd:element maxOccurs="1" minOccurs="1" name="zipcode"

nillable="true" type="xsd:string"/> <xsd:element maxOccurs="1" minOccurs="1" name="windSpeed"

nillable="true" type="xsd:unsignedInt"/> <xsd:element maxOccurs="1" minOccurs="1" name="sky" nillable="true"

type="xsd:string"/> <xsd:element maxOccurs="1" minOccurs="1" name="temp" nillable="true"

type="xsd:int"/> </xsd:complexType> </xsd:schema> </types>

<type> Element Continued..

This types element contains a complete XML Schema. The schema defines a single complexType named WeatherSummary.

The WeatherSummary type contains a “zipcode” element of type xsd:string, a “windSpeed” element of type xsd:unsignedInt, a “sky” element of type xsd:string, and a “temp” element of type xsd:int.

<message> Element

Defines the content of a message that the service supports.

Each message holds one or more part elements.

A part reference a parameter in the message.

The parts can be compared to the parameters of a function call in a traditional programming language.

<message> Element Continued..

Sample of <message> element. <message name="MessageName">

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

Name Attribute: Specify the name of the message and name of

part in the case of respective elements . Other elements in the WSDL document use this

name to refer to this message.

Example of a <message>

<message name="getSummary">

<part name="zipcode" type="xsd:string"/>

</message>

<message name="getSummaryResponse">

<part name="return" type=“wsx:WeatherSummary"/>

</message>

The message named getSummary consists of a string named zipcode.

The message named getSummaryResponse consists of a WeatherSummary named return

<portType> Element

A port type is a named set of abstract operations . An operation is a set of messages. The <portType> element can be compared to a function library (or a

module, or a class) in a traditional programming language.

Example: <portType name="nmtoken"> <operation name="nmtoken" .... /> <input message=“input message name"/> <output message=“output message name"/> <

</operation> </portType>

Example

<message name="getTermRequest"> <part name="term" type="xs:string"/></message> <message name="getTermResponse"> <part name="value" type="xs:string"/> </message>

<portType name="glossaryTerms"> <operation name="getTerm"> <input message="getTermRequest"/> <output message="getTermResponse"/> </operation

</portType>

Compared to traditional programming, glossaryTerms is a function library, "getTerm" is a function with "getTermRequest" as the input parameter and getTermResponse as the return parameter.

Types of Operations

One-way. The endpoint receives a message. Request-response. The endpoint receives a

message, and sends a correlated message. Solicit-response. The endpoint sends a

message, and receives a correlated message. Notification. The endpoint sends a message.

One-Way

The outline for a one-way operation is:

<portType name="nmtoken">

<operation name="nmtoken" .... />

<input message=“message name"/>

</operation>

</portType> The input element specifies the abstract message format

for the request operation.

Request-response Operation

The outline for a request-response operation is: <portType name="nmtoken"> <operation name="nmtoken" .... /> <input message=“input message name"/> <output message=“output message name"/> <fault message = “fault message name”/>

</operation> </portType>

The input element specifies the abstract message format for the request operation.

The output element specifies the abstract message format for the response operation.

The fault element specifies the message format for the error messages

Solicit-response Operation

The outline for a solicit-response operation is:

<portType name="nmtoken">

<operation name="nmtoken" .... />

<output message=“output message name"/>

<input message=“input message name"/>

<fault message = “fault message name”/>

</operation> </portType>

Notification Operation

The outline for a notification operation is:

<portType name="nmtoken">

<operation name="nmtoken" .... />

<output message=“output message name"/>

</operation> </portType>

<binding> Element

A binding element describes a specific communication protocol for a portType element.

Each binding corresponds to a portType in the WSDL document.

The binding element describes the specific protocol for each message in each operation of the portType element.

<binding> Element Continued…

<binding name="nmtoken" type="qname"> <-- extensibility element--> <operation name="nmtoken"> <input name="nmtoken"? > <-- extensibility element--> </input> <output name="nmtoken"? > <-- extensibility element--> <output> <fault name="nmtoken"> <-- extensibility element--> <fault> </operation> </binding>

Extensibility Elements

<soap:binding> The soap:binding element specifies that the binding protocol

is SOAP.

“style” attribute specifies whether the operation is RPC- oriented (messages containing parameters and return values) or document-oriented (message containing document).

<soap:body> The soap:body binding element provides information on how

to assemble the different message parts.

<service> Element

A service element describes a Web service as a collection of port elements.

A port element defines a specific network address for a binding.

<service> Element Continued…

Outline of Service Element: <service name="ServiceName">

<port name="PortName" binding="BindingRef"> <soap:address location="URL"/>

</port> </service> Name attribute specifies a unique name for the service

and port. Binding attribute of <port> specifies the binding

reference to which the network address is asscociated. The network address of the “ServiceName” is specified by the <soap:address> elements’s “location”

attribute.

References

Links: http://www.w3.org/TR/wsdl.html

http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/dnarxml/html/wsdlexplained.asp

http://www.systinet.com/doc/ssj60/primerj/primerj.wsprimer.wsdl.htm http://www.roguewave.com/support/docs/leif/leif/html/leifug/B-1.html Books: Author: Newcomer, Eric. Title: Understanding Web services : XML, WSDL, SOAP, and

UDDI / Eric Newcomer.