ppt slides

T-110.5140 Network Application
Frameworks and XML
Web Services and WSDL
02.04.2007
Sasu Tarkoma
Based on slides by Pekka Nikander
What is WSDL?


WSDL: Web Service Description Language
An XML language used to describe and locate
web services





Commonly used to describe SOAP-based
services
W3C standard (work in progress)




location of web service
methods that are available
data type information and XML messages
Initial input: WSDL 1.1 as W3C Note
Current version 2.0 (Candidate Recommendation)
Some differences between 1.1 and 2.0
WSDL 1.1 in WS-I Basic Profile 1.0 and 1.1.
WSDL Document Elements
(v.1.1.)






<types> - data type definitions
<message> - Abstract definition of the
data being transmitted
<portType> - A set of abstract
operations
<binding> - Concrete protocol and data
format specifications for the operations
and messages defined by a particular
portType. Endpoint type.
<port> - An address for binding.
Endpoint instance.
<service> - A set of ports.
WSDL Overview
<definitions>: ROOT WSDL element
<types>: The data types that are used
<message>: What messages are transmitted?
<portType>: The supported operations
<binding>: The binding to concrete protocols
<service>: Reference to actual location
A WSDL Document


A WSDL document contains two parts
Abstract part


Concrete part


Interfaces, types, messages
Binding to conrete protocol and encoding
May be published separately


Interfaces agreed between many companies
Each company published their own
implementation in UDDI and import the
abstract interface.
Mapping SOAP to WSDL
6 of 20
Message Styles



The WSDL 1.1 specification defines two SOAP
message styles
Determined in binding
Document




<soap:Body> contains one or more child elements
called parts
There are no SOAP formatting rules for what the
<soap:Body> contains
preferred, loose coupling, easy validation
RPC



<soap:Body> contains an element with the name
of the method or remote procedure being invoked
This element in turn contains an element for each
parameter of the procedure
less popular today, tighter coupling
The main structure (v.1.1)
<definitions namespace = "http://..">
<types>XML Schema types</types>
<message>..</message>
<portType>a set of operations</portType>
<binding>Communication protocols</binding>
<service>A list of binding and ports</service>
</definitions>
Types


<types> define data types used in
message declaration
For platform neutrality, WSDL uses XML
Schema syntax to define data


XML Schema must be supported by any
vendor of WSDL conformant products
Other kinds of type definitions also possible


Possible interoperability issues
If the service uses only XML Schema built-in
simple types, such as strings and integers,
the types element is not required
WSDL Messages

The <message> element defines the
data elements of an operation





the name of the message
contains zero or more message part elements
The parts can be compared to the
parameters of a function call in a
traditional programming language
All parts are typed by an XML Schema
type
V.2.0 changes: message element is not
used, replaced by patterns
WSDL Ports




The <portType> element is the most
important WSDL element
The operations that can be performed,
the messages that are involved
A <port> defines the connection point to
a web service, an instance of <portType>
It can be compared to a function library
(or a module, or a class) in a
programming language
Operation Types (v.1.1)





One-Way: The operation can receive a
message but will not return a response
Request-Response: The operation can
receive a request and will return a
response
Solicit-Response: The endpoint sends an
output message and then receives an
input message.
Notification: The operation can send a
message but will not wait for a response
v.2.0 changes: abstract message
patterns
<message name="GetLastTradePriceInput">
<part name="body" element="TradePriceRequest"/>
</message>
<message name="GetLastTradePriceOutput">
<part name="body" element="TradePrice"/>
</message>
<message name=”ExampleInteraction">
<part name="index" type="xsd:integer"/>
<part name="name" type="xsd:string" />
</message>
Example
<portType name="StockQuotePortType">
<operation name="GetLastTradePrice">
<input message="tns:GetLastTradePriceInput"/>
<output message="tns:GetLastTradePriceOutput"/>
</operation>
</portType>
One way and Notification Example
<portType name="RegisterPort">
<operation name="register">
<input name="customerInfo" message="RegInfo"/>
</operation>
<operation name="registerResponse">
<output name="response" message="ResponseInfo"/>
</operation>
</portType>
Putting it together
Source: http://msdn.microsoft.com/
WSDL 2.0


3 specifications
Part 1: Core


Part 2: Message Exchange Patterns


Predefined types of interactions
Part 3: Bindings


Abstract interfaces, independent of protocol
and encoding
SOAP and HTTP/MIME binding
Lot’s of changes from 1.1
Changes from 1.1 to 2.0




Adding further semantics to the
description language.
Removal of message constructs. These
are specified using the XML schema type
system in the types element.
No support for operator overloading.
PortTypes renamed to interfaces.
Support for interface inheritance is
achieved by using the extends attribute
in the interface element.

Ports renamed to endpoints.

Abstracted message patterns
WSDL 2.0 Conceptual Model
Source: http://webservices.xml.com/pub/a/ws/2004/05/19/wsdl2.html
Message Exchange Patterns
MEP
Description
Fault
in-only
Single input message
No
robust-in-only
Single input message
Trigger
In-out
Input message + output message Replace
out-only
Single output message
No
robust-only-out
Single output message
Trigger
out-in
Output followed by input msg
Replace
out-optional-in Output followed by an opt. Input
Trigger
in-optional-out Input followed by an opt. Output
Trigger
Implementations

Microsoft .NET


Java API for XML-based RPC (JAX-RPC)



SOAP 1.1, WSDL 1.1
Java API for XML Registries (JAXR)
Apache Axis




SOAP 1.1, WSDL 1.1
Tools for automatically creating WSDL to/from
Java
SOAP 1.1 and 1.2, WSDL 1.1, JAX-RPC 1.0
Axis2 supports WSDL 2.0 component model
IBM Websphere, BEA Web Logic, SAP
NetWeaver, …
Uses of WSDL documents

Description of service interfaces

Compile-time


Run-time


Developer uses WSDL before service
deployment
Client downloads WSDL description and uses
the info it provides to execute the service
As a side-effect



Developers can use WSDL to speed up the
development of code
WSDLJava code
Java interfaces  WSDL
Summary


Deferred binding, using Web,
composition
Some details and conventions still
unclear


Possible interoperability issues
Parts hard to understand




Namespaces
Schemas
Differences between versions
Document vs. RPC SOAP style


Also literal vs. encoded
More about this next week