Top Banner
T-110.455 Network Application Frameworks an XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander
55

T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

Jan 12, 2016

Download

Documents

Rosalind Watts
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: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

T-110.455 Network Application Frameworks and XML

Web Services and WSDL

16.3.2005

Sasu Tarkoma

Based on slides by Pekka Nikander

Page 2: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

Contents

Short review of XML & related specs Web Services

Driving forces Architecture & protocol stack

WSDL 1.1 WSDL document elements Mapping SOAP to WSDL

WSDL 2.0 Implementations Towards the Semantic Web Summary

Page 3: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

XML

XML (eXtensible Markup Language) is a framework for defining markup languages

Standardized by W3C Idea: to separate syntax from semantics,

custom markup, internationalization, platform independence

XML Document: prolog, elements, attributes, entity references, comments

Validated using DTD or schema Two things: well-formedness and validity

Page 4: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

Related standards

Namespaces Modular document definition, multiple

inheritance, collision avoidance XPath / XQuery

Navigation and query of parts of the document XML linking language (Xlink) XML Schema

definition of document structure and custom data types

XSLT Transformation of documents

Page 5: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

Namespaces Many documents can have identical elements that

denote different things Namespaces are the XML way to classify elements A qualified name is a name subject to namespace

interpretation

W3C Recommendation In general, a namespace is just a tag

An arbitrary string Does not need to be a URI

A common practice to store a schema / WSDL into the place referenced by the URI Semantics depends on the specific platform Some XML validators use these

Page 6: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

Example namespace

<!-- the 'price' element's namespace is

http://ecommerce.example.org/schema -->

<edi:price

xmlns:edi='http://ecommerce.example.org/schema'

units='Euro'>32.18</edi:price>

Page 7: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

About Schemas

XML language for describing and constraining the content of XML documents

A W3C Recommendation Used to specify

The allowed structure of an XML document The allowed data types contained in XML

documents XML Schema documents are XML documents Schema document: schema element and

element, attribute, and type definitions + annotations

Page 8: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

Driving forces I

Universal data access / representation Independent of OS, programming language,

network protocol, … Move from human-centric to application-

centric web Applications converse with each other and

use machine-related information published on the web

Application-areas: package tracking, card verification, shopping bots, single sign-on, calendar, email, ...

Page 9: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

Driving forces II

Making Web a programming interface We have had servlets, CGI, CORBA for years Idea is to standardise languages and

protocols to have better integration Make service composition possible

Faster project throughput Cope with heterogeneity

Deferred binding Many levels of deference

Page 10: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

A Basic Web Service

Computer ALanguage: C++

OS: W2000

Computer ALanguage: C++

OS: W2000

Computer BLanguage: Java

OS: Linux

Computer BLanguage: Java

OS: Linux

XML

XML

Independent oflanguage, OS, network

protocols

Page 11: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

Additional properties

A web service should be self-describing Interface is published with the implementation Minimum interface is human readable

description The interface can also be written in a

common XML grammar (WSDL) A web-service should be discoverable

The web service is published Interested parties can find it

Not mandatory but desirable properties

Page 12: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

Standardization

W3C Web Services XML Protocol Working Group

SOAP Web Services Addressing Working Group Web Services Choreography Working Group Web Services Description Working Group

WSDL

OASIS E-business standards, UDDI

WS-I (Web Service Interoperability Org.) Binding profiles,..

Page 13: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

Web Service Architecture

The three major roles in web services Service provider

Provider of the WS Service Requestor

Any consumer / client Service Registry

logically centralized directory of services

A protocol stack is needed to support these roles

Page 14: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

XML Messaging

Several alternatives for XML messaging XML Remote Procedure calls (XML-RPC) SOAP Regular XML transported over HTTP

XML-RPC

SOAP

HTTP POST/GET

Page 15: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

SOAP Version 1.2

The definition of the XML-based information for exchanging structured and typed information between peers

A SOAP message is formally specified as an XML Infoset

Infosets can have different on-the-wire representations, one common example of which is as an XML 1.0 document.

A stateless, one-way message exchange paradigm Applications can create more complex interaction

patterns request/response, request/multiple responses

Page 16: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

Web Services Protocol Stack

Message Transport Responsible for transporting messages HTTP, BEEP

XML Messaging Responsible for encoding messages in common XML

format XML-RPC, SOAP

Service Description Responsible for describing an interface to a specific web

service WSDL

Service discovery Responsible for service discovery and search UDDI

Page 17: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

WS Protocol Stack

Transport: HTTP, FTP, BEEP, SMTP, JMSTransport: HTTP, FTP, BEEP, SMTP, JMS

XML Messaging: SOAP, XML-RPC, XMLXML Messaging: SOAP, XML-RPC, XML

Description: WSDLDescription: WSDL

Discovery: UDDIDiscovery: UDDI

Page 18: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

Main components today

XML data representation XML Schema Definitions (xsd) for types XML Namespaces for unambiguity

SOAP Basic transport (XML messaging) Sync / async communication and RPC

WSDL Description of (SOAP) services

UDDI Service registry

Page 19: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

Example WS layering

Transport: HTTP(S), SMTP, JMS, ..Transport: HTTP(S), SMTP, JMS, ..

XML processorXML processor

SOAP processorSOAP processor

Serialization / deserialization (java to XML mapping)Serialization / deserialization (java to XML mapping)

Service containerService container J2EE integrationJ2EE integration

Management services:Admin, UDDI, depl., auditingManagement services:Admin, UDDI, depl., auditing

Page 20: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

How it could work

1. A standard body creates a WSDL definition

2. A service programmer implements a service according to the WSDL definition

3. A client programmer implements a client according to the WSDL definition

4. A service provider deploys the sevice, and registers it into UDDI

5. A client program pulls WSDL from UDDI, checks conformance, an uses SOAP for access

Page 21: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

2. Creating server application

Pull WSDL definition from somewhere (UDDI) Only use high-level WSDL, no bindings yet

Generate platform specific skeleton code using automated tools

Write the actual program code

Page 22: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

3. Creating client application

Pull WSDL definition from somewhere (UDDI) Use only high-level WSDL, no bindings yet

Generate platform specific stub code using automated tools

Write the actual program code

Page 23: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

4. Deploying the service

UDDIUDDIWSDL

documentWSDL

document

WSDLportTypeWSDL

portType

WSDLbindingWSDLbindingWS serviceWS service

SOAP proc.SOAP proc.

TransportTransport

Page 24: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

5. Using a service

UDDIUDDI

WSDLportTypeWSDL

portType

WSDLbindingWSDLbinding

WS serviceWS service

SOAP proc.SOAP proc.

TransportTransport

WSDLdocumentWSDL

document

Page 25: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

About invocation mechanisms

WS does not define an invocation mechanism

Alternatives Microsoft .NET framework Java-based framework

JAVA API for WSDL (JWSDL) JAX-RPC Java API for XML registries (JAXR) Apache Axis ...

Page 26: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

WSDL with Java

Services

WSDL document

JAXR

UDDI

Publish

firewall

WS requester

Business partneror other system

SOAP RQBind

SOAP RQ

SOAP RQ

1. WSDL is publishedto UDDI

2. Look up WS

3. Retrieve WSDLdescription

4. Call WS

JAXR=Java API for XML Registries

Page 27: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 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 location of web service methods that are available data type information and XML messages

Commonly used to describe SOAP-based services

W3C standard (work in progress) Initial input: WSDL 1.1 as W3C Note Current version 2.0 (last call) Some differences between 1.1 and 2.0

WSDL 1.1 in WS-I Basic Profile 1.0 and 1.1.

Page 28: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

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 an data

format specifications for the operations and messages defined by a particular portType

<port> - An address for binding <service> - Aggregate a set of related ports

Page 29: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

WSDL Overview

<definitions>: ROOT WSDL element

<types>: The data types that are used<types>: The data types that are used

<message>: What messages are transmitted?<message>: What messages are transmitted?

<portType>: The supported operations<portType>: The supported operations

<binding>: The binding to concrete protocols<binding>: The binding to concrete protocols

<service>: Reference to actual location<service>: Reference to actual location

Page 30: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

A WSDL Document

A WSDL document contains two parts Abstract part

Interfaces, types, messages Concrete part

Binding to conrete protocol and encoding

Page 31: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

31 of 20

Mapping SOAP to WSDL

Page 32: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

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

Page 33: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

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>

Page 34: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

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

Page 35: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

<types> <schema targetNameSpace="http://example.com/stockquote.xsd" xmlns:xsd="http://www.w3c.org/2000/10/XMLSchema"> <element name="TraderPriceRequest"> <complexType> <all> <element name="tickerSymbol" type="xsd:string"

minOccur="1" maxOccur="10"/> <element name="payment"> <complexType>

<choice> <element name="account" type="xsd:string"/> <element name="ccard" type="xsd:string"/></choice>

</complexType> </element </all> </complexType> </element> </schema></types>

Specifies that the child elements can appear in any order. Each child element

can occur 0 or 1 time

Namespace definitions

Only one of the elements is allowed

Page 36: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

Corresponding XML instance

<TraderPriceRequest><tickerSymbol>ABC</tickersymbol><payment><account>1234</account></payment></TraderPriceRequest>

Page 37: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

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

Page 38: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

<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>

Page 39: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

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

Page 40: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

Example

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

</portType>

Page 41: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

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

Page 42: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

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>

Page 43: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

Bindings

The <binding> element defines The message format and protocol details

Page 44: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

Example

<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>

Must use for document-style.

For RPC style type encoding info

is eliminated. Difference is that for

RPCliteral params have schemas but

the whole body does not.

Specifies that the SOAPAction HTTP header be used for identifying the service

RPC or document. RPC has a wrapperfor func. Names & params

Page 45: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

Service

Real-life address of the service A URL containing a DNS name

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

Page 46: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

Putting it together

Source: http://msdn.microsoft.com/

Page 47: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

WSDL 2.0

3 specifications Part 1: Core

Abstract interfaces, independent of protocol and encoding

Part 2: Message Exchange Patterns Predefined types of interactions

Part 3: Bindings SOAP and HTTP/MIME binding

Lot’s of changes from 1.1

Page 48: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

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

Page 49: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

WSDL 2.0 Conceptual Model

Source: http://webservices.xml.com/pub/a/ws/2004/05/19/wsdl2.html

Page 50: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

WSDL 2.0 Component Model

Source: https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/documents/a1-8-4/First%20Look%20at%20WSDL%202.0.article

Page 51: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

Message Exchange Patterns

MEP

in-only

robust-in-only

In-out

out-only

robust-only-out

out-in

out-optional-in

Description

Single input message

Output followed by an opt. Input

Input message + output message

Single output message

Single output message

Output followed by input msg

Single input message

Fault

No

Trigger

Replace

No

Trigger

Replace

Trigger

in-optional-out Input followed by an opt. Output Trigger

Page 52: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

Implementations

Microsoft .NET SOAP 1.1, WSDL 1.1

Java API for XML-based RPC (JAX-RPC) SOAP 1.1, WSDL 1.1

Java API for XML Registries (JAXR) Apache Axis

Tools for automatically creating WSDL to/from Java

SOAP 1.1 and 1.2, WSDL 1.1, JAX-RPC 1.0 IBM Websphere, BEA Web Logic, SAP

NetWeaver, …

Page 53: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

What about semantics?

In many cases, applications (or agents) need to deduce and infer about information

In order to make this possible Semantic information is needed

Tim Berners Lee, the inventor of the WWW, has proposed the Semantic Web Application centric Semantic and logic layers

Page 54: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

Semantic Web layers

Unicode URI

XML+Namespaces+XML Schema

Trust

ProofRules

LogicData

Ontology vocabularyData

RDF + RDF SchemaDoc

Dig.

Sig.

Page 55: T-110.455 Network Application Frameworks and XML Web Services and WSDL 16.3.2005 Sasu Tarkoma Based on slides by Pekka Nikander.

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