What are Web Services? - Connect

41
CSM 002 / Advanced Dist. Sys. [http://www.cheswick.com/ches/map/] Session 2.1a Web Services François Taïani

Transcript of What are Web Services? - Connect

Page 1: What are Web Services? - Connect

CSM 002 / Advanced Dist. Sys.

[http

://w

ww

.che

swic

k.co

m/c

hes/

map

/]

Session 2.1a Web Services

François Taïani

Page 2: What are Web Services? - Connect

Associated Reading Reading

Newcomer chapter 1: “Introducing Web Services” Web Services Architecture specification

http://www.w3.org/TR/ws-arch/ Example services – www.xmethods.net

Page 3: What are Web Services? - Connect

Outline Definition of Web Services

Why Web Services? – Motivation

Interaction Styles Web Service Architecture and Core Technologies

SOAP, WSDL, UDDI

The case of REST

Page 4: What are Web Services? - Connect

What are Web Services? Emerging distributed systems technology

Loosely-coupled, Service-oriented approach Major industrial players (IBM, Microsoft, etc.) behind it

Major recent step in improving interoperability CORBA, EJB provide tightly coupled interoperability Web Services aims to provide open integration

An evolving Web standard World Wide Web Consortium (W3C) http://www.w3.org/2002/ws/

Development still on-going! (as of 2010)

Page 5: What are Web Services? - Connect

What is a Web Service? Often incorrectly described or misinterpreted

“A Web Service is a software system designed to supportinteroperable machine-to-machine interaction over anetwork. It has an interface described in a machine-processable format (specifically WSDL). Other systemsinteract with a web service in a manner prescribed by itsdescription using SOAP messages, typically conveyedusing HTTP with an XML serialisation in conjuction withother Web related standards.” WSA specification 08/08/03

Page 6: What are Web Services? - Connect

Why Web Services (1) ? What is middleware good at?

Overcoming heterogeneity and Interoperability problems

Common problems Tightly coupled client/server models Development between specified parties (companies A & B)

What is the WWW good at? Human interaction with text and graphics Open publication of information

Can we utilise the WWW to support application toapplication interaction?

Page 7: What are Web Services? - Connect

AmazonAmazon.co.ukAmazon.co.ukPlay.comAmazon.co.uk

CNN BBCi

Discover & Interact

The World Wide Web (WWW) Web pages published to a wide audience

Open to read by anyone

Client can dynamically search, choose and browse

Page 8: What are Web Services? - Connect

Why Web Services (2)?

Take existing software & make it widely available Existing legacy code, database, CORBA objects, EJB …

Applications can dynamically discover services that meettheir requirements Software-oriented interactions automatically perform

operations that previously required manual intervention

Page 9: What are Web Services? - Connect

An example application

Calendar on PDA9pm:Reservation atParisrestaurant Restaurant

WebService

HotelWeb

Service

AirlineWeb

Service

Grand Hotel

Ibis Hotel

British Airways

EasyJet

Air France

Page 10: What are Web Services? - Connect

Why Web Services (3)? Software solutions heterogeneously implemented

Different middleware e.g. EJB, DCOM and CORBA services Problem of Enterprise Application Integration

Web Services are abstract entities Higher level framework of interoperation The same client can interoperate with any implementation

Page 11: What are Web Services? - Connect

Web Services Interactions Middleware typically encompasses a single interaction style

Web Services offer a higher level abstraction,encompassing: RPC, Asynchronous messaging, One-way messaging,

Broadcast & Publish\Subscribe

However, only two styles are typically used Remote Procedure Call Documented Oriented Messaging (more on this with REST)

Page 12: What are Web Services? - Connect

Remote Procedure CallInteractive Order request/response

Page 13: What are Web Services? - Connect

Document Oriented InteractionWorkflow of purchase order

Page 14: What are Web Services? - Connect

Web Services in Action Web Services are available for you to use today

Google E.g. Google Maps API -http://code.google.com/apis/maps/index.html

Amazon S3 storage service, catalogue apihttp://docs.amazonwebservices.com/AmazonS3/latest/API/

Flickrhttp://www.flickr.com/services/api/

Microsoft Live E-bay

http://developer.ebay.com/developercenter/soap/ And many others

Page 15: What are Web Services? - Connect

Example: Combining Services Google Maps + craigslist rentals= housingmaps.com

Page 16: What are Web Services? - Connect

16

WS architecture

serviceprovider

servicerequester

Serviceregistry

4. bind and invoke

3. discover (+ discover

and compose)2. publish (+ compose

and publish)

(1. describe)

Page 17: What are Web Services? - Connect

UDDI

WSDL

SOAP

XML

WS Core Technologies

Discovery

Description

Interaction

Page 18: What are Web Services? - Connect

XML (Extensible Markup Language) Basic foundation of Web Services

Base language for defining data and how to process it

Overcomes limitations of HTML Data has meaning Elements (tags) associate meaning with data

XML Schemas ensures that everyone uses the sameelements in the same way

If two parties share an XML document and the same XMLschema they understand the same content

This is exactly how Web Services work All messages exchanged are XML documents

Page 19: What are Web Services? - Connect

Example XML

Page 20: What are Web Services? - Connect

SOAP The SOAP specification defines a messaging framework

designed for exchanging formatted XML data across theInternet.

Neutral with respect to operating system, programminglanguage, or distributed computing platform.

Fundamentally, a one-way communication model Adapted to perform RPC Transfer complete XML documents

Abstract communication protocol Bridge between heterogeneous implementations

Page 21: What are Web Services? - Connect

An Abstract Comm. Protocol

Page 22: What are Web Services? - Connect

22

Web Services Description Language How does the caller of a SOAP Web Service know

what operations are available, what parameters they need,what kind of response to expect, etc?

what underlying protocol to use for a request (e.g. HTTP,SMTP, ...)?

what network address to send the request to?

We could provide a textual description of the requiredinformation, but this would be messy and inconducive toautomation

We need a "formal" approach that is susceptible tosoftware tooling—enter WSDL...

Page 23: What are Web Services? - Connect

23

WSDL (cont.) WSDL: an XML dialect for defining the interface of each

Web Service interoperability is only possible if both sender & receiver

share and understand same WSDL specification

WSDL is a key technology in supporting enterpriseapplication integration separation of abstract service description from concrete

messaging format users can focus on the former and ignore the latter

WSDL specifications are divided into three major elements data type definitions abstract (message and port) definitions service bindings

Page 24: What are Web Services? - Connect

WSDL Elements

Page 25: What are Web Services? - Connect

A Metaphor A bit like electric distribution

distinction between type ("blueprint") andinstances (actual thing)

data type: voltage and frequency i.e. what will be transported can change from one country to an other

abstract message and port definitions how should the plugs look like? Blueprint for plugs

service bindings how a particular electrical installation is wired must respect voltage and plug standards of the country many low level details: What kind of metal for wiring

(copper?)? What isolation layer (PVC)? ...

Page 26: What are Web Services? - Connect

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

Data Type Definitions

Page 27: What are Web Services? - Connect

<?xml version="1.0"?><definitions name="StockQuote" ... xmlns="http://www.w3.org/2003/11/wsdl" ...>

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

Abstract Message and Port Type

Page 28: What are Web Services? - Connect

<?xml version="1.0"?><definitions name="StockQuote" ... xmlns="http://schemas.xmlsoap.org/wsdl/"> <import ../> <binding name="SQuoteBinding" type="tns:StockQuotePortType"> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> <operation name="GetLastTradePrice"> <soap:operation

soapAction="http://stockquote.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:SQuoteBinding"> <soap:address location="http://stockquote.com/stockquote"/> </port> </service></definitions>

Service Bindings

Page 29: What are Web Services? - Connect

Discovering Web Services3 styles Registry style

Authoritative, centrally controlled e.g. UDDI

Index approach Open, centralized, free market model 3rd party information included E.g. Google index

Peer-to-Peer discovery Decentralised, suited to alternative environments e.g.

ubiquitous, ad-hoc

Page 30: What are Web Services? - Connect

UDDI: Publishing & Discovering WS

Universal Description, Discovery & Integration (UDDI) A Web Service registry & discovery mechanism for retrieving

pointers for web services interfaces

UDDI is like a yellow pages directory Companies register extra contact information

Vendors Publish information about services

Clients search for matching services

Centralised discovery mechanism No longer used for public repositories

but still used internally

Page 31: What are Web Services? - Connect

WS Limitations and REST

Argument: The Web Service Stack is heavyweight Difficult to understand Difficult to implement Interoperability is still difficult to achieve

Alternative model: RESTful Web services XML services using just the HTTP protocol Loosely coupled, message orientation

Page 32: What are Web Services? - Connect

So what is REST? REST = Representational State Transfer

a collection of architectural principles for large scaledistributed systems

first presented in Roy Fielding’s doctoral dissertation aboutthe web

the principles underlying HTTP (Roy Fielding was one of theprincipal authors of HTTP)

Structured around verbs (only a few) and nouns (many) nouns identified a resource (URI or URL in http) verbs are “generic” actions of those resources:

GET, POST, PUT, DELETE

Page 33: What are Web Services? - Connect

REST’s Generic Actions GET:

obtained the state of a resource

POST: update the state of a resource (non idempotent)

PUT: replace the state of a resource with a new version

(idempotent)

DELETE: delete the resource

Page 34: What are Web Services? - Connect

REST First Example: UNIX

In UNIX, everything is a file file, but also sockets, pipes, devices, etc. a limited generic interface: open, close, read, write

(+the, for some infamous, ioctrl command)

Page 35: What are Web Services? - Connect

2nd Example: Locating Users Imagine a RPC application with the following functions

getUser() addUser() removeUser() updateUser() getLocation()addLocation() removeLocation() updateLocation() listUsers()listLocations() findLocation() findUser()

RESTful version: Two resource types: User {} and Location {} URI for each individual user and location Updating a user: PUTting some XML at the corresponding

URI:<user> <name>Jane User</name> <gender>female</gender> <location href="http://w.e.org/l/us/ny/NYC"> New York City, NY, US</location></user>

source: http://en.wikipedia.org/wiki/Representational_State_Transfer

Page 36: What are Web Services? - Connect

SOAP, RPC, & SOAP-RPC SOAP was originally RPC inspired, linked to

WSDL: Web Service Definition Language (kind of IDL) XSD: XML Schema Definition Language (kind of CDR) WSRF: Web Service Resource Framework (adding state) WS-N: Publish subscribe service (notification) WS-A: Addressing (how to describe routing, endpoints...)

Those standard are managed by the W3C and OASIS World Wide Web Consortium: XSD, SOAP, WSDL, WSA, ... Orgtion for the Advancement of Structured Inftion Standards http://www.oasis-open.org

But SOAP can be used without any of these Hence its neutral status

Page 37: What are Web Services? - Connect

SOAP for RPC (Mainly taken from Loughran and Smith’s article)

Involves using the WSDL and XSD formats WSDL defines operations available (roughly) XSD the type of data that are exchanged

The pure way to do so: First write WSDL and XSD files (complex and laborious) Then implement the corresponding service and clients

Not the easiest way Many developers use tools that hide this complexity One of the most popular: JAX-RPC (standard) and Axis

(realises the standard)

Page 38: What are Web Services? - Connect

But SOAP is more than RPC

e.g. Web Services Are Not Distributed Objects, WernerVogels, IEEE Internet Computing, Nov./Dec. 2003

Web services: XML document design is the key issue protocols and addresses are necessary only as glue: getting

the document to the right place in the right manner

Page 39: What are Web Services? - Connect

RPC vs. REST (Some) References:

Architectural Styles and the Design of Network-basedSoftware Architectures, Roy Thomas Fielding, DoctoralDissertation, University of California, Irvine, 2000

RESTful Web Services: An introduction building to WebServices without tears, J. Cowan, XML 2005, tutorial, Nov. 14-18 2005, Atlanta, USA

Web Services Are Not Distributed Objects, Werner Vogels,IEEE Internet Computing, 2003 (Vol. 7, No. 6) pp. 59-66

Rethinking the Java SOAP Stack, Steve Loughran, EdmundSmith, TR HPL-2005-83 20050517, Hewlett-Packard, 2005

RPC Under Fire, Steve Vinoski (IONA Technology), IEEEInternet Computing, Sept./Oct. 2005 issue

Page 40: What are Web Services? - Connect

Analysis: WS The new silver bullet to interoperability problems?

Web Services do not solve much by themselves Web Services are a new layer, or another way of doing things Important because they bridge technology domains

Allow new Interaction styles

Promote open publication of software services Solve Enterprise Application Integration

XML & WSDL are the key technologies

Page 41: What are Web Services? - Connect

Expected Learning OutcomesAt the end of this session you should be able to:

explain the rationale for, benefits and limitation of WebServices

be able to compare Web Services with other middlewaretechnology

explain the principles and roles of the technologies at thecore of Web Services (SOAP, WSDL, UDDI)

explain the different style of WS design, in particularbetween a REST and RPC-based approaches