Top Banner
EGEE is a project funded by the European Union under contract IST-2003-508833 WSDL Web Service Description Language www.eu-egee.org
25

EGEE is a project funded by the European Union under contract IST-2003-508833 WSDL Web Service Description Language .

Mar 28, 2015

Download

Documents

Ashton Arnold
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: EGEE is a project funded by the European Union under contract IST-2003-508833 WSDL Web Service Description Language .

EGEE is a project funded by the European Union under contract IST-2003-508833

WSDL Web Service Description

Language

www.eu-egee.org

Page 2: EGEE is a project funded by the European Union under contract IST-2003-508833 WSDL Web Service Description Language .

Talk title date 2

Objectives

The role of WSDLThe structure of a WSDL document

typesmessageportTypebindingservice

Page 3: EGEE is a project funded by the European Union under contract IST-2003-508833 WSDL Web Service Description Language .

Talk title date 3

What is the function of WSDL

WSDL represents a contract between the consumer and provider of a service.

It should guarantee a service format.

Page 4: EGEE is a project funded by the European Union under contract IST-2003-508833 WSDL Web Service Description Language .

Talk title date 4

The function of WSDL

WSDL describes a service’s exposed interface

It is what a client sees of your service

WSDL includes information aboutThe data types it usesParameters it requires and returnsGroupings of functionalityThe protocol to be used to access the serviceThe location or address of the service

Page 5: EGEE is a project funded by the European Union under contract IST-2003-508833 WSDL Web Service Description Language .

Talk title date 5

WSDL StructureA WSDL document is an XML document

<?xml version="1.0" encoding="UTF-8"?><definitions> <types>

<!– define the types here using XML Schema </types> <message>

<!– XML messages the web service uses are defined here </message> <portType>

<!– define the input and output parameters here - </portType> <binding>

<!– define the network protocol here </binding> <service>

<!– location of the service </service></definitions>

Page 6: EGEE is a project funded by the European Union under contract IST-2003-508833 WSDL Web Service Description Language .

Talk title date 6

Referencing between sections

<?xml version="1.0" encoding="UTF-8"?><definitions> <types>

<!– define the data types here using XML Schema </types> <message>

<!– The message will refer to the types defined above </message> <portType>

<!– The operations refer to the messages defined above - </portType> <binding>

<!– A binding refers to a portType defined above </binding> <service>

<!– The service refers to a particular binding defined above </service></definitions>

Each section refers to elements defined in other sections

Page 7: EGEE is a project funded by the European Union under contract IST-2003-508833 WSDL Web Service Description Language .

Talk title date 7

Simplified definitions

Each defines things referenced by other sections

Page 8: EGEE is a project funded by the European Union under contract IST-2003-508833 WSDL Web Service Description Language .

Talk title date 8

<import> element

<definitionstargetNamespace=“urn:3950”xmlns= “http://schema.xmlsoap.org/wsdl/”xmlns:xsd= “http://www.w3c.org/2001/XMLSchema”xmlns:soap= “http://schemas.xmlsoap.org/wsdl/soap/”xmlnssoapenc= “http://schemas.xmlsoap.org/soap/emcoding/”xmlns:tns= “urn:3950”>

<import namespace= “http://nesc.ac.uk” location= “http://nesc.ac.uk/ez.xsd”/>

Acts like C/C++ #include , or Java import. Incorporates external namespaces

Page 9: EGEE is a project funded by the European Union under contract IST-2003-508833 WSDL Web Service Description Language .

Talk title date 9

Namespaces

WSDL uses a number of different namespaces including

XML Schema Namespaceshttp://www.w3.org/2000/10/XMLSchema http://www.w3c.org/2001/XML-Schema-instance

WSDL Namespaceshttp://schemas.xmlsoap.org/wsdl/soap/http://schemas.xmlsoap.org/wsdl/

SOAP Namespaceshttp://schemas.xmlsoap.org/soap/encodinghttp://schemas.xmlsoap.org/soap/envelope

Page 10: EGEE is a project funded by the European Union under contract IST-2003-508833 WSDL Web Service Description Language .

Talk title date 10

The <types>

The types element contains XML Schemas defining the datatypes that are to be passed to and from the web service

<types> <schema targetNamespace="http://example.com/stockquote.xsd" xmlns="http://www.w3.org/2000/10/XMLSchema"> <element name="TradePriceRequest"> <complexType> <all><element name="tickerSymbol" type="string"/></all> </complexType> </element> <element name="TradePrice"> <complexType> <all><element name="price" type="float"/></all> </complexType> </element> </schema> </types>

Page 11: EGEE is a project funded by the European Union under contract IST-2003-508833 WSDL Web Service Description Language .

Talk title date 11

The <message>

The <message> element is used to define the messages that will be exchanged between the client and the serviceThese message elements contain <part> elements, which will be using types defined in the types element

All the parts are namespace qualified

<message name="GetLastTradePriceInput"> <part name="body" element="xsd1:TradePriceRequest"/> </message>

<message name="GetLastTradePriceOutput"> <part name="body" element="xsd1:TradePrice"/></message>

Page 12: EGEE is a project funded by the European Union under contract IST-2003-508833 WSDL Web Service Description Language .

Talk title date 12

Relating messages and operations

Web services are a messaging system

For a normal method (operation) there will be generally two messages

A message is required to pass the parameters in.

A message is required to pass the return value out

Even a void return requires an ‘empty’ return message

Page 13: EGEE is a project funded by the European Union under contract IST-2003-508833 WSDL Web Service Description Language .

Talk title date 13

Messaging

void myMethod (parameter:type)

Empty message

Parameter:type

1. Message in

2. Message out

In non-messaging languages this is hidden

Page 14: EGEE is a project funded by the European Union under contract IST-2003-508833 WSDL Web Service Description Language .

Talk title date 14

The <portType>

The types and messages have been defined, but they have not been defined in terms of where they fit in the functionality of the web service

This is done within <portType> and <operation> elements

A portType is analogous to a classAn operation is analogous to a method in that class

<portType name="StockQuotePortType"> <operation name="GetLastTradePrice"> <input message="tns:GetLastTradePriceInput"/> <output message="tns:GetLastTradePriceOutput"/> </operation></portType>

Page 15: EGEE is a project funded by the European Union under contract IST-2003-508833 WSDL Web Service Description Language .

Talk title date 15

Types of <operation>There are four distinct types of operationSynchronous

Request-response - The service receives a message and sends a replySolicit-response - The service sends a message and receives a reply message

AsynchronousOne-way - The service receives a messageNotification - The service sends a message

All of these can be defined in WSDL

Page 16: EGEE is a project funded by the European Union under contract IST-2003-508833 WSDL Web Service Description Language .

Talk title date 16

Defining the type of operation

Presence and order of input/output elements defines the type of operation.

Request-response <input><output>

Solicit-response <output><input>

One-way <input> only

Notification <output> only

Page 17: EGEE is a project funded by the European Union under contract IST-2003-508833 WSDL Web Service Description Language .

Talk title date 17

Page 18: EGEE is a project funded by the European Union under contract IST-2003-508833 WSDL Web Service Description Language .

Talk title date 18

The <binding> element

This element is used to define the mechanism that the client will actually use to interact with the web serviceThere are three possibilities1. SOAP2. HTTP3. MIMEThe most common choice is currently SOAPThe binding element defines the protocol specific information for the portTypes previously defined

Page 19: EGEE is a project funded by the European Union under contract IST-2003-508833 WSDL Web Service Description Language .

Talk title date 19

The binding tag<binding name=“ez3950SOAPBinding” type=“tns:ez3950PortTypes”>

The <binding> tag indicates that we will map a <Port Type> to a protocol

<soap:binding style=“rpc” transport=“http://schemas.xmlsoap.org/soap/http/”>

Indicates we will be using the SOAP binding extensions to map the operations.

The alternative to “rpc” is “document”.

( to use GET/POST use <http:binding…> to use MIME use <mime:binding…..> )

Page 20: EGEE is a project funded by the European Union under contract IST-2003-508833 WSDL Web Service Description Language .

Talk title date 20

<binding> Example

Below is an example of a binding element for SOAP

<binding name="StockQuoteSoapBinding“ type="tns:StockQuotePortType"> <soap:binding style="document“ transport="http://schemas.xmlsoap.org/soap/http"/> <operation name="GetLastTradePrice"> <soap:operation soapAction="http://example.com/GetLastTradePrice"/>

<input> <soap:body use="literal"/></input><output> <soap:body use="literal"/></output>

</operation></binding>

Page 21: EGEE is a project funded by the European Union under contract IST-2003-508833 WSDL Web Service Description Language .

Talk title date 21

<service>

The final component of a WSDL file is the <service> elementThe <service> element defines <port> elements that specify where requests should be sent

The <soap:address> subelement identifies the URL of the service

The precise content of <port> elements will be dependent upon the mechanism, i.e. SOAP, HTTP or MIME

<service name="StockQuoteService"> <port name="StockQuotePort" binding="tns:StockQuoteBinding"> <soap:address location="http://example.com/stockquote"/> </port></service>

Page 22: EGEE is a project funded by the European Union under contract IST-2003-508833 WSDL Web Service Description Language .

Talk title date 22

Overview of HelloService

Page 23: EGEE is a project funded by the European Union under contract IST-2003-508833 WSDL Web Service Description Language .

Talk title date 23

<?xml version="1.0" encoding="UTF-8"?> <definitions name="HelloService" targetNamespace="http://www.ecerami.com/wsdl/HelloService.wsdl" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.ecerami.com/wsdl/HelloService.wsdl" xmlns:xsd="http://www.w3.org/2001/XMLSchema">  

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

</message> <message name="SayHelloResponse">

<part name="greeting" type="xsd:string"/> </message>   <portType name="Hello_PortType">

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

</operation> </portType>  

Page 24: EGEE is a project funded by the European Union under contract IST-2003-508833 WSDL Web Service Description Language .

Talk title date 24

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

transport="http://schemas.xmlsoap.org/soap/http"/> <operation name="sayHello">

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

<soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"

namespace="urn:examples:helloservice" use="encoded"/> </input> <output>

<soap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"

namespace="urn:examples:helloservice" use="encoded"/> </output>

</operation> </binding>

Page 25: EGEE is a project funded by the European Union under contract IST-2003-508833 WSDL Web Service Description Language .

Talk title date 25

<service name="Hello_Service"> <documentation>WSDL File for

HelloService</documentation> <port binding="tns:Hello_Binding" name="Hello_Port"> <soap:address

location="http://localhost:8080/soap/servlet/rpcrouter"/></port>

</service> </definitions>