web service description language

23
Session 2 Web Services Description Language (WSDL)

Upload: tracy-hnil

Post on 27-May-2017

221 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Web Service Description Language

Session 2Web Services Description

Language (WSDL)

Page 2: Web Service Description Language

XML Web Services with Java / Session 2 / 2 of 23

Review of Session 1 (1 of 2)

Web Services are self-contained, self-describing, modular applications that can be published, located and invoked across the Web.

The service interface in a Web Service helps the Web Service to be called by any other application program or another Web Service.

A Web Service should be registered in a service registry to be accessed by other programs.

Web Services use the standard Web protocols to communicate unlike COM, RMI, JINI, or CORBA.

XML messages are used to interchange information between the service and the application program.

Page 3: Web Service Description Language

XML Web Services with Java / Session 2 / 3 of 23

Review of Session 1 (2 of 2) A service provider along with a service registry,

a service broker and a service requestor form the important participants in a Web Service.

A Web Service architecture primarily consists of the following layers:

Data store Data access Web Service logic Web Service logic facade Listener layer

Page 4: Web Service Description Language

XML Web Services with Java / Session 2 / 4 of 23

Session Objectives Justify the need for a service description

language Describe WSDL Discuss a simple Web service and its WSDL file Describe WSDL terminologies Analyze a WSDL file Explain the role of SOAP in WSDL

Page 5: Web Service Description Language

XML Web Services with Java / Session 2 / 5 of 23

Service Description Language (SDL)

Platform A

Service 1

………….………….………….

Platform B

Service 2

………….………….………….

Description of service written

in SDL

Specifies functionality of serviceLists the parameters required by the exposed methodLists parameters returned by methodsDocuments the Web service contract (messages that the Web Service will generate and accept)

Compatibility Issues

Page 6: Web Service Description Language

XML Web Services with Java / Session 2 / 6 of 23

Web Service Description Language (WSDL) (1)

Web Service

Consumer

………………………

Web Service

XML file describing

Web services acts as a contract

between the Web service consumer

and the Web service

Page 7: Web Service Description Language

XML Web Services with Java / Session 2 / 7 of 23

Web Service Description Language (WSDL) (2)

WSDL Document

Network Accessible Service Specification Language (NASSL)

Well Defined Service Document (WDS)

XML based Interface Definition Language used to specify operational information for a Web Service.

Specifies non-operational information for a service viz. service category, expiry date, company name etc.

Page 8: Web Service Description Language

XML Web Services with Java / Session 2 / 8 of 23

A Simple Web Service Interface

Output in XML format can be consumed by other Web services

Page 9: Web Service Description Language

XML Web Services with Java / Session 2 / 9 of 23

The WSDL File<?xml version="1.0" encoding="utf-8" ?> - <definitions xmlns:s="http://www.w3.org/2001/XMLSchema“ ..... xmlns="http://schemas.xmlsoap.org/wsdl/">+ <types>+ <message name="addSoapIn">

.........................+ <message name="addHttpPostOut">+ <portType name="TestWSSoap">..........................+ <portType name="TestWSHttpPost">+ <binding name="TestWSSoap" type="s0:TestWSSoap">

.........................+ <binding name="TestWSHttpPost “type="s0:TestWSHttpPost">+ <service name="TestWS"> </definitions>

Namespaces

elements

Page 10: Web Service Description Language

XML Web Services with Java / Session 2 / 10 of 23

WSDL Terminologies (1)

CLIENT

SOAP Operation

HTTP Operation

Ports

Ports

Web Service

SOAP Request

SOAP Response

HTTP Response

HTTP Request

Page 11: Web Service Description Language

XML Web Services with Java / Session 2 / 11 of 23

WSDL Terminologies (2) message: Abstract definition of the data being communicated types: Mechanism to define data type used in Web service operation: Abstract definition of a particular action supported

by the Web service port: An end-point described by the combination of a network

address and binding portType: Collection of operations binding: Specification that lists the communication protocol

and the data format for a particular port type service: Defined as a collection of ports

Page 12: Web Service Description Language

XML Web Services with Java / Session 2 / 12 of 23

The Analysis of a WSDL File ‘definitions’ element is the root

component of the WSDL file

Page 13: Web Service Description Language

XML Web Services with Java / Session 2 / 13 of 23

Elements of a WSDL File

services

bindingsportTypes

messages

types

Platform and Language IndependentAbstract Definitions

Machine or Language Specific

Concrete Definitions

modifies

operations

ports

Page 14: Web Service Description Language

XML Web Services with Java / Session 2 / 14 of 23

types Describes data types used for exchanging

messages by the service. - <types> - <s:schema attributeFormDefault=“qualified” elementFormDefault=“qualified” targetNamespace=http://tempuri.org/> - <s:element name=“add”> - <s:complexType> - <s:sequence> ...... </s:sequence> </s:complexType> </s:element> ..... </s:schema> </types>

Page 15: Web Service Description Language

XML Web Services with Java / Session 2 / 15 of 23

message Specifies the service’s request and response

mechanism Not dependent upon any protocol i.e. there is

no naming convention for message names. Divided into parts and each part is defined by

the <part> element- <message name="addSoapIn"> <part name="parameters" element="s0:add" /> </message>- <message name="addSoapOut"> <part name="parameters" element="s0:addResponse" /> </message> ........

Page 16: Web Service Description Language

XML Web Services with Java / Session 2 / 16 of 23

portType Operations (input output messages) are to

be defined by specifying the <operation> element

portType defines operations provided by the Web Service.

<portType name="TestWSSoap">- <operation name="add"> <input message="s0:addSoapIn" /> <output message="s0:addSoapOut" /> </operation></portType>......................

Page 17: Web Service Description Language

XML Web Services with Java / Session 2 / 17 of 23

binding Represents the concrete descriptions of the operations Specifies the representation of parameters for a Web method

<binding name="TestWSSoap" type="s0:TestWSSoap"><soap:binding transport= http://schemas.xmlsoap.org/soap/http style="document" /> -<operation name="add"> <soap:operation soapAction=http://tempuri.org/add style="document" /> - <input><soap:body use="literal" /></input>- <output><soap:body use="literal" /></output></operation> </binding>.......

Page 18: Web Service Description Language

XML Web Services with Java / Session 2 / 18 of 23

service Specifies methods offered by the Web service Services are available on ports, which have

specific addresses

<service name="TestWS">- <port name="TestWSSoap" binding="s0:TestWSSoap"> <soap:address location="http://localhost/ws.asmx" /> </port>- <port name="TestWSHttpGet" binding="s0:TestWSHttpGet"> <http:address location="http://localhost/ws.asmx" /> </port> .....</service>

Page 19: Web Service Description Language

XML Web Services with Java / Session 2 / 19 of 23

SOAPLightweight protocol that can be used over HTTP, SMTP etc.

Can be easily adapted with firewalls

Standard for communicating with Web services

WSDL specifies the protocols supported by a Web service

Page 20: Web Service Description Language

XML Web Services with Java / Session 2 / 20 of 23

Sample Code (SOAP Request)

POST /ws.asmx HTTP/1.1Host: localhostContent-Type: text/xml; charset=utf-8Content-Length: lengthSOAPAction: "http://tempuri.org/add"<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd=http://www.w3.org/2001/XMLSchema

xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <add xmlns="http://tempuri.org/"> <a>int</a> <b>int</b> </add> </soap:Body></soap:Envelope>

Replace with actual values

Page 21: Web Service Description Language

XML Web Services with Java / Session 2 / 21 of 23

Sample Code (SOAP Response)

HTTP/1.1 200 OKContent-Type: text/xml; charset=utf-8Content-Length: length<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap= "http://schemas.xmlsoap.org/soap/envelope/"><soap:Body> <addResponse xmlns="http://tempuri.org/"> <addResult>int</addResult> </addResponse> </soap:Body></soap:Envelope>

Replace with actual values

Page 22: Web Service Description Language

XML Web Services with Java / Session 2 / 22 of 23

Summary (1 of 2) The language used to describe a service is

known as Service Description Language (SDL). The language used to describe the services

offered by a Web Service is known as Web Service Description Language (WSDL).

WSDL is a subset of two separate documents, NASSL (Network Accessible Service Specification Language) and WDS (Well Defined Service document).

An operation is an abstract definition of a particular action supported by the Web Service. A set of input and output messages collectively defines an operation.

Page 23: Web Service Description Language

XML Web Services with Java / Session 2 / 23 of 23

Summary (2 of 2) types is a mechanism to define the data types

used in the Web Service. For example, XSD (XML Style Definition).

binding specifies a list of communication protocols and data formats for a particular port type. A binding specifies the manner in which operations will access the service using a certain protocol.

A WSDL file can be classified into two sections: Abstract Definitions Concrete Descriptions