+ All Categories
Home > Documents > WSDL - Arizona State University...4 What is WSDL? • XML language for describing web services •...

WSDL - Arizona State University...4 What is WSDL? • XML language for describing web services •...

Date post: 31-May-2020
Category:
Upload: others
View: 1 times
Download: 0 times
Share this document with a friend
36
1 WSDL Basics WSDL Basics (Web Services (Web Services Description Language) Description Language)
Transcript
Page 1: WSDL - Arizona State University...4 What is WSDL? • XML language for describing web services • Web service is described as – A set of communication endpoints (ports) • Endpoint

1

WSDL Basics WSDL Basics (Web Services (Web Services

Description Language)Description Language)

Page 2: WSDL - Arizona State University...4 What is WSDL? • XML language for describing web services • Web service is described as – A set of communication endpoints (ports) • Endpoint

2

Agenda● What and Why WSDL?● Example WSDL Document ● WSDL Document Elements● Importing & authoring style● Application design & Tools● Limitations of WSDL● WSDL 1.2

Page 3: WSDL - Arizona State University...4 What is WSDL? • XML language for describing web services • Web service is described as – A set of communication endpoints (ports) • Endpoint

3

What is and Why What is and Why WSDL?WSDL?

Page 4: WSDL - Arizona State University...4 What is WSDL? • XML language for describing web services • Web service is described as – A set of communication endpoints (ports) • Endpoint

4

What is WSDL?• XML language for describing web services• Web service is described as

– A set of communication endpoints (ports) • Endpoint is made of two parts

– Abstract definitions of operations and messages – Concrete binding to networking protocol (and

corresponding endpoint address) and message encoding

• Why this separation?– Enhance reusability (of the abstract part, for

example)

Page 5: WSDL - Arizona State University...4 What is WSDL? • XML language for describing web services • Web service is described as – A set of communication endpoints (ports) • Endpoint

5

What is WSDL?

source: WSDL 1.2 primer

Page 6: WSDL - Arizona State University...4 What is WSDL? • XML language for describing web services • Web service is described as – A set of communication endpoints (ports) • Endpoint

6

Where is WSDL Used?

UDDI serviceUDDI Registry

Web

Web servicerequester

Web

Web servicerequester

Business partner or other system

Web serviceprovider

JAXRServlets

WSDL Document

(1) Register web service

(2) Search for web service

(3) Retrieve WSDL definition

(4) Invoke web service

soap request

Soap request

Soap requestSoap request

Page 7: WSDL - Arizona State University...4 What is WSDL? • XML language for describing web services • Web service is described as – A set of communication endpoints (ports) • Endpoint

7

Why WSDL?

• Enables automation of communication details between communicating partners– Machines can read WSDL– Machines can invoke a service defined in WSDL

• Discoverable through registry • Arbitration

– 3rd party can verify if communication conforms to WSDL

Page 8: WSDL - Arizona State University...4 What is WSDL? • XML language for describing web services • Web service is described as – A set of communication endpoints (ports) • Endpoint

8

WSDL DocumentWSDL DocumentStructure Structure

Page 9: WSDL - Arizona State University...4 What is WSDL? • XML language for describing web services • Web service is described as – A set of communication endpoints (ports) • Endpoint

9

WSDL Document Structure<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl" targetNamespace="your namespace here" xmlns:tns="your namespace here" xmlns:soapbind="http://schemas.xmlsoap.org/wsdl/soap"> <wsdl:types> <xs:schema targetNamespace="your namespace here (could be another) " xmlns:xsd="http://www.w3.org/2001/XMLSchema" <!-- Define types and possibly elements here --> </schema> </wsdl:types> <wsdl:message name="some operation input"> <!-- part(s) here --> </wsdl:message> <wsdl:message name="some operation output"> <!-- part(s) here --> </wsdl:message> <wsdl:portType name="your type name"> <!-- define operations here in terms of their messages --> </wsdl:portType> <wsdl:binding name="your binding name" type="tns:port type name above"> <!-- define style and transport in general and use per operation --> </wsdl:binding> <wsdl:service> <!-- define a port using the above binding and a URL --> </wsdl:service></wsdl:definitions>

Page 10: WSDL - Arizona State University...4 What is WSDL? • XML language for describing web services • Web service is described as – A set of communication endpoints (ports) • Endpoint

10

WSDL Namespaces● http://schemas.xmlsoap.org/wsdl● http://schemas.xmlsoap.org/wsdl/soap● http://www.w3.org/2001/XMLSchema

Page 11: WSDL - Arizona State University...4 What is WSDL? • XML language for describing web services • Web service is described as – A set of communication endpoints (ports) • Endpoint

11

Example WSDL Example WSDL

Document Document

Page 12: WSDL - Arizona State University...4 What is WSDL? • XML language for describing web services • Web service is described as – A set of communication endpoints (ports) • Endpoint

12

WSDL Document Example● Simple service providing stock quotes● A single operation called

GetLastTradePrice● Deployed using SOAP 1.1 over HTTP● Request takes a ticker symbol of type

string● Response returns price as a float

Page 13: WSDL - Arizona State University...4 What is WSDL? • XML language for describing web services • Web service is described as – A set of communication endpoints (ports) • Endpoint

13

● Types● Message● Operation● Port Type ● Binding● Port● Service

WSDL Elements

Page 14: WSDL - Arizona State University...4 What is WSDL? • XML language for describing web services • Web service is described as – A set of communication endpoints (ports) • Endpoint

14

WSDL Elements ● Types– Data type definitions – Used to describe exchanged messages– Uses W3C XML Schema as canonical type

system

Page 15: WSDL - Arizona State University...4 What is WSDL? • XML language for describing web services • Web service is described as – A set of communication endpoints (ports) • Endpoint

15

WSDL Example: Types<definitions name="StockQuote" targetNamespace="http://example.com/stockquote.wsdl" xmlns:tns="http://example.com/stockquote.wsdl" xmlns:xsd1="http://example.com/stockquote.xsd" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns="http://schemas.xmlsoap.org/wsdl/”> <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 16: WSDL - Arizona State University...4 What is WSDL? • XML language for describing web services • Web service is described as – A set of communication endpoints (ports) • Endpoint

16

WSDL Elements● Messages– Abstract, typed definitions of data being

exchanged● Operations – Abstract description of an action– Refers to an input and/or output messages

● Port type– Collection of operations– Abstract definition of a service

Page 17: WSDL - Arizona State University...4 What is WSDL? • XML language for describing web services • Web service is described as – A set of communication endpoints (ports) • Endpoint

17

Example: Messages, Operation, Port type<message name="GetLastTradePriceInput"> <part name="body" element="xsd1:TradePriceRequest"/></message>

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

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

Page 18: WSDL - Arizona State University...4 What is WSDL? • XML language for describing web services • Web service is described as – A set of communication endpoints (ports) • Endpoint

18

WSDL Elements● Binding– Concrete protocol and data format (encoding)

for a particular Port type● Protocol examples: SOAP 1.1 over HTTP or SOAP

1.1 over SMTP● Encoding examples: SOAP encoding, RDF encoding

● Port– Defines a single communication endpoint– Endpoint address for binding– URL for HTTP, email address for SMTP

● Service– Aggregate set of related ports

Page 19: WSDL - Arizona State University...4 What is WSDL? • XML language for describing web services • Web service is described as – A set of communication endpoints (ports) • Endpoint

19

Example: Binding, Port, Service<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>

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

Page 20: WSDL - Arizona State University...4 What is WSDL? • XML language for describing web services • Web service is described as – A set of communication endpoints (ports) • Endpoint

20

WSDL Document

WSDL View of a Web Service

Service ABinding "FooB"

SOAP/HTTP

Port Type "FooPT"

Operation "Op1"

Operation "Op2"Service B

Port "Bar"

Port "Xyz"

Port ...

Http://.../foo

Port "Foo"

Page 21: WSDL - Arizona State University...4 What is WSDL? • XML language for describing web services • Web service is described as – A set of communication endpoints (ports) • Endpoint

21

Web Service Invocation

Part

Part

Message

Client Service

Each Message part is of somedate type. Use XSD predefined types, e.g. xsd : int or define yourown

The input and output messagesform an operation. A collectionof these operations form a porttype

SOAP/HTTP requestmessage

HTTP GET requestmessage

Port 2

Port 1

SOAP/HTTP responsemessage

HTTP GET responsemessage

A binding specifies how operations are accessed using a particular protocol e.g. SOAP over HTTP

Page 22: WSDL - Arizona State University...4 What is WSDL? • XML language for describing web services • Web service is described as – A set of communication endpoints (ports) • Endpoint

22

More Detailed More Detailed Description onDescription on

WSDL ElementsWSDL Elements

Page 23: WSDL - Arizona State University...4 What is WSDL? • XML language for describing web services • Web service is described as – A set of communication endpoints (ports) • Endpoint

23

Message Element● Consist of one or more logical parts● Syntax

<definitions .... > <message name="nmtoken"> * <part name="nmtoken" element="qname"? type="qname"?/> * </message></definitions>

– element attribute refers to an XSD element using a QName

– type attribute refers to an XSD simpleType or complexType using a QName

Page 24: WSDL - Arizona State University...4 What is WSDL? • XML language for describing web services • Web service is described as – A set of communication endpoints (ports) • Endpoint

24

Example: Message Element<definitions .... > <types> <schema .... > <element name="PO" type="tns:POType"/> <complexType name="POType"> <all> <element name="id" type="string/> <element name="name" type="string"/> <element name="items"> <complexType> <all> <element name="item" type="tns:Item" minOccurs="0" maxOccurs="unbounded"/> </all> </complexType> </element> </all> </complexType>

<complexType name="Item"> <all> <element name="quantity" type="int"/> <element name="product" type="string"/> </all> </complexType> <element name="Invoice" type="tns:InvoiceType"/> <complexType name="InvoiceType"> <all> <element name="id" type="string"/> </all> </complexType> </schema> </types>

<message name="PO"> <part name="po" element="tns:PO"/> <part name="invoice" element="tns:Invoice"/> </message></definitions>

Page 25: WSDL - Arizona State University...4 What is WSDL? • XML language for describing web services • Web service is described as – A set of communication endpoints (ports) • Endpoint

25

Types of Operations● One-way– The endpoint receives a message

● Request/response– The endpoint receives a message, and sends

a correlated message● Notification– The endpoint sends a message

● Solicit/response– The endpoint sends a message, and receives

a correlated message

Page 26: WSDL - Arizona State University...4 What is WSDL? • XML language for describing web services • Web service is described as – A set of communication endpoints (ports) • Endpoint

26

One-way Operation<operation name=”submitPurchase”> <input message=”purchase”/></operation>

Page 27: WSDL - Arizona State University...4 What is WSDL? • XML language for describing web services • Web service is described as – A set of communication endpoints (ports) • Endpoint

27

Request/Response Operation<operation name=”submitPurchase”> <input message=”purchase”/> <output message=”confirmation”/></operation>

<operation name=”submitPurchase”> <input message=”purchase”/> <output message=”confirmation”/> <fault message=”faultMessage”/></operation>

Page 28: WSDL - Arizona State University...4 What is WSDL? • XML language for describing web services • Web service is described as – A set of communication endpoints (ports) • Endpoint

28

Notification Operation<operation name=”deliveryStatus”> <output message=”trackingInformation”/></operation>

Page 29: WSDL - Arizona State University...4 What is WSDL? • XML language for describing web services • Web service is described as – A set of communication endpoints (ports) • Endpoint

29

Solicit/Response Operation<operation name=”clientQuery”> <output message=”bandwidthRequest”/> <input message=”bandwidthInfo”/> <fault message=”faultMessage”/></operation>

Page 30: WSDL - Arizona State University...4 What is WSDL? • XML language for describing web services • Web service is described as – A set of communication endpoints (ports) • Endpoint

30

Importing &Importing &Authoring StyleAuthoring Style

Page 31: WSDL - Arizona State University...4 What is WSDL? • XML language for describing web services • Web service is described as – A set of communication endpoints (ports) • Endpoint

31

Authoring Style Recommendation● Reusability and maintainability● Maintain WSDL document in 3

separate parts – Data type definitions– Abstract definitions– Specific service bindings

● Use “import” element to import necessary part of WSDL document

Page 32: WSDL - Arizona State University...4 What is WSDL? • XML language for describing web services • Web service is described as – A set of communication endpoints (ports) • Endpoint

32

Example7A: http://example.com/stockquote/stockquote.xsd

<?xml version="1.0"?><schema targetNamespace="http://example.com/stockquote/schemas" 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>

Page 33: WSDL - Arizona State University...4 What is WSDL? • XML language for describing web services • Web service is described as – A set of communication endpoints (ports) • Endpoint

33

Example7B: http://example.com/stockquote/stockquote.wsdl<?xml version="1.0"?><definitions name="StockQuote"

targetNamespace="http://example.com/stockquote/definitions" xmlns:tns="http://example.com/stockquote/definitions" xmlns:xsd1="http://example.com/stockquote/schemas" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns="http://schemas.xmlsoap.org/wsdl/">

<import namespace="http://example.com/stockquote/schemas" location="http://example.com/stockquote/stockquote.xsd"/>

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

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

Page 34: WSDL - Arizona State University...4 What is WSDL? • XML language for describing web services • Web service is described as – A set of communication endpoints (ports) • Endpoint

34

Example7C: http://example.com/stockquote/stockquoteservice.wsdl

<?xml version="1.0"?><definitions name="StockQuote"targetNamespace="http://example.com/stockquote/service" xmlns:tns="http://example.com/stockquote/service" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:defs="http://example.com/stockquote/definitions" xmlns="http://schemas.xmlsoap.org/wsdl/">

<import namespace="http://example.com/stockquote/definitions" location="http://example.com/stockquote/stockquote.wsdl"/>

<binding name="StockQuoteSoapBinding" type="defs: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> <service name="StockQuoteService"> <documentation>My first service</documentation> <port name="StockQuotePort" binding="tns:StockQuoteBinding"> <soap:address location="http://example.com/stockquote"/> </port> </service></definitions>

Page 35: WSDL - Arizona State University...4 What is WSDL? • XML language for describing web services • Web service is described as – A set of communication endpoints (ports) • Endpoint

35

WSDL 1.2WSDL 1.2

Page 36: WSDL - Arizona State University...4 What is WSDL? • XML language for describing web services • Web service is described as – A set of communication endpoints (ports) • Endpoint

36

WSDL 1.2

● Described in XML Information set● Aligned with SOAP 1.2– Changes are mostly about SOAP binding

● MEP (Message Exchange Pattern)● Clarifications– Solicit-response and notification model

● Still “work in progress” state


Recommended