ooti course distributed systemswsinmak/education/ooti/l4_webservices.pdf• uddi for web services...
TRANSCRIPT
OOTI course
Distributed Systems
2013, Sep. 26 – Oct 01
Lecture 4: Web Services
Agenda
• Introduction
• Motivation
• Definition
• Architectural styles
• Naming: URIs
• Web services technologies
• Orchestration
• Replication
R.H. Mak PAGE 127-9-2013
Motivation
The desire for an open distributed system
• Interoperability and portability
• on a global scale, i.e., across the Internet
• on arbitrary hardware and software platforms
• at multiple quality levels
• Extendibility
• with new resources and services
• with contributions from various vendors/ developers
R.H. Mak PAGE 227-9-2013
Basic organization of the Web
R.H. Mak PAGE 327-9-2013
Many variations on this scheme, e.g.,
• Client-side caching• Clusters of servers• Multiple-tiers
No indication how the
client discovers theservice!
Layers and client / server functionality
• 3-layer organization of data access: cuts possible at many places
• cuts define tiers
• (a,b) thin client – changing control
− the user interface has small overhead; it typically runs on a machine that is a client to the application server
− however, after connection, the user interface becomes a server for the application
• (c,d) thick client
• (e) file server
PAGE 427-9-2013J.J. Lukkien
Combining layering and C/S in a distributed fashion
• Development (logical): layering (“presentation, business and data tier (layer)”)
• Deployment: Client-Server interactions between the components• also called: multi-tier client-server organization
• note: middle layer plays both client and server roles− that is actually what layering + request/reply is
PAGE 527-9-2013J.J. Lukkien
Web service
“A Web service is nothing but a “traditional service” that is made available over the Internet.” (quote from TvS)
• Adheres to a collection of standards that allow it to be discoveredand accessed over the Internet by client applications that adhere to those standards
• Can be composed of more elementary services. The cooperation of elementary services that constitute a complex service need to be coordinated
Service oriented architectures organize the application’s services plus services needed for discovery, coordination (and many more) into a distributed system.
R.H. Mak PAGE 627-9-2013
Service
• a unit of functionality
• coarse-grained, e.g., stock market ticker, not a mathematical function like the sinus.
• accessed via a well-defined interface
• delivered at a well-defined quality level
• Agreed upon by server provider and consumer in a service level agreement (SLA)
A service is a logical concept. A service is realized by a component. Components that provide the same service can (will) differ in their non-functional properties depending on their vendor/developer.
R.H. Mak PAGE 727-9-2013
• Motivation:• Separate functionality (“service”), the
implementation, the deployment context and the application context
• Build applications by very late (dynamic) binding• Integration of enterprise information systems
• Vocabulary• SOA, service, interface, discovery, composition,
binding, orchestration, choreography
• Rules• Application is built ad-hoc out
of services that communicate in a standardized manner− via a network− see e.g. REST
• Service is a self-containedfunctionality. It does not depend on state of otherservices, or of the system (OS, language) it is running on.
• Services are discoverable
• Structure (conceptual):
• Typical behavior• Providers publish services; Applications
(“orchestrations”) discover services, and bind their interfaces− Service broker (registry) can exist to manage
discovery process
• Applications send data objects through a number of services as a work flow − Often XML based RPC (SOAP)− Services are typically kept simple and focused on
single task
Service oriented (SOA) style
Note: SOA is a huge research domain in business information systems
PAGE 827-9-2013J.J. Lukkien
Enterprise application organization
PAGE 927-9-2013J.J. Lukkien
RESTful Web service
A RESTful Web service is a Web service
• that is resource-oriented, i.e., organized as a set of resources
• Documents of various types are served to clients (similar to WWW)
• Not only static documents, but also dynamically generated upon request
• Resources may have multiple representations (e.g. in English and Chinese)
• Format for representations is free, although XML is popular
• in which all operations on resources are cast in the form of a CRUD-operation (create, read, update, delete)
• HTTP-messages (GET,PUT,POST,DELETE) are used to specify those
operations;
• URLs both specify the (location of) the resource and parameters for the
operation; often a HTTP message consist of a header only, thus creating a
light-weight protocol with a uniform interface
− e.g. GET http://www.example.com/MyBookmarks?topic=webservices to obtain a list of bookmarks, instead of a RPC getMyBookmarks(webservices)
R.H. Mak PAGE 1027-9-2013
RESTful Web service
• that is stateless;
• servers do not maintain application state, i.e., information from previous interactions with a client, hence the client must supply this information in
successive operations
• of course, servers maintain resource state, in the form of representations
• that supports client-side caching
• Through HTTP cache control mechanisms
• that support code on demand
• Servers may send code necessary to execute other representations they
have sent
• Usually JAVAscript
R.H. Mak PAGE 1127-9-2013
REST: REpresentational State Transfer
• Motivation:• special usage of C&S aiming at
− portability− independent development & deployment− reduction of interaction complexity− reliability
− scalability
• Vocabulary• user agent, origin server, gateway, proxy• cache, layer• state• code-on-demand• resource, resource identifier (e.g. URL),
representation, metadata
• Rules• stateless communication (no server state)• response is labeled as cache-able, and can then
be cached• uniform interface between components
− decouples structure from functionality
• layering• client functionality can be adapted by code-on-
demand
• Structure
(model in the process view from R. Fielding, Architectural Styles and the
Design of Network-based Software Architectures)
• Typical behavior
• as (layered) C&S, but only a single service (interface)
• Prime example: WWW
PAGE 1227-9-2013
Recap: naming on the Web
R.H. Mak PAGE 1327-9-2013
• Often-used structures for URLs.
a) Using only a DNS name.
b) Combining a DNS name with a port number.
c) combining an IP address with a port number.
• By means of Uniform Resource Identifiers (URIs)• either a URL(ocator) or a URN(ame);on the Web mostly URLs
Recap question:
How are these Names resolved?
Agenda
• Introduction
• Web services technologies
• SOAP
• WSDL,
• WADL
• UPnP
• Orchestration
• Replication
R.H. Mak PAGE 1427-9-2013
Messages use carrier protocols
R.H. Mak PAGE 1527-9-2013
EXAMPLE ?
Messages use carrier protocols
R.H. Mak PAGE 1627-9-2013
On the Web, HTTP serves as the bottle.
SOAP message in an envelope
envelope
header
body
header element
body element
header element
body element
PAGE 1727-9-2013R.H. Mak
Instructor’s Guide for Coulouris, Dollimore, Kindberg and Blair, Distributed Systems: Concepts and Design Edn. 5 © Pearson Education 2012
Example: simple request without headers
m:exchange
env:envelope xmlns:env =namespace URI for SOAP envelopes
m:arg1
env:body
xmlns:m = namespace URI of the service description
Hellom:arg2
World
In this figure and the next, each XML element is represented by a shaded box with its name in italic followed by any attributes and its content
PAGE 1827-9-2013R.H. Mak
Instructor’s Guide for Coulouris, Dollimore, Kindberg and Blair, Distributed Systems: Concepts and Design Edn. 5 © Pearson Education 2012
Example: reply corresponding to the request
env:envelope xmlns:env = namespace URI for SOAP envelope
m:res1
env:body
xmlns:m = namespace URI for the service description
m:res2World
m:exchangeResponse
Hello
PAGE 1927-9-2013R.H. Mak
Instructor’s Guide for Coulouris, Dollimore, Kindberg and Blair, Distributed Systems: Concepts and Design Edn. 5 © Pearson Education 2012
Example: Soap request in xml format
• POST /InStock HTTP/1.1Host: www.example.orgContent-Type: application/soap+xml; charset=utf-8Content-Length: nnn
<?xml version="1.0"?><soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
<soap:Body xmlns:m="http://www.example.org/stock"><m:GetStockPrice>
<m:StockName>IBM</m:StockName></m:GetStockPrice>
</soap:Body>
</soap:Envelope>
R.H. Mak PAGE 2027-9-2013
©Taken from http://www.w3schools.com/soap/soap_example.asp
SOAP
=
HTTP
+
XML
Notice:No header
Example: SOAP response
• HTTP/1.1 200 OKContent-Type: application/soap+xml; charset=utf-8Content-Length: nnn
<?xml version="1.0"?><soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
<soap:Body xmlns:m="http://www.example.org/stock"><m:GetStockPriceResponse>
<m:Price>34.5</m:Price></m:GetStockPriceResponse>
</soap:Body>
</soap:Envelope>
R.H. Mak PAGE 2127-9-2013
Example: SOAP response
HTTP/1.1 200 OKContent-Type: application/soap+xml; charset=utf-8Content-Length: nnn
<?xml version="1.0"?><soap:Envelopexmlns:soap="http://www.w3.org/2001/12/soap-envelope"soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
<soap:Body xmlns:m="http://www.example.org/stock"><m:GetStockPriceResponse><m:Price>34.5</m:Price>
</m:GetStockPriceResponse></soap:Body>
</soap:Envelope>
R.H. Mak PAGE 2227-9-2013
©Taken from http://www.w3schools.com/soap/soap_example.asp
Web service description
• Defines the service
• the interface (functionality)
• the location and the communication protocols used
− URI, HTTP, SOAP,,XML, …
• machine readable format
− WSDL
• Is stored in a repository and made available through a directory service
• UDDI for Web services
• Facilitates the development of clients and servers
• Through automatic generation of stubs stubs for RPC
R.H. Mak PAGE 2327-9-2013
Web-service model
R.H. Mak PAGE 2427-9-2013
WSDL: document structure
R.H. Mak PAGE 2527-9-2013
<definitions>
<types>definition of types....
</types>
<message>definition of a message....
</message>
<portType><operation>
definition of a operation.... </operation>
</portType>
…..
The service interfacefor each operation its messages and their types (in, out) are listed
The target namespace:
complex data structures specified using XML
Messages associated with operationsContaining parameter listor result list
The abstract part of the service description
WSDL: document structure (cntd)
R.H. Mak PAGE 2627-9-2013
…..<binding>
definition of a binding.... </binding>
<service>definition of a service....
</service>
</definitions>
The concrete part of the service description
How the service is exposedEndpoint
Binding
The protocol usedMessage format
Data representation
WSDL example: message and portType element
<message name="getTermRequest"><part name="term" type="xs:string"/>
</message>
<message name="getTermResponse"><part name="value" type="xs:string"/>
</message>
<portType name="glossaryTerms"><operation name="getTerm"><input message="getTermRequest"/><output message="getTermResponse"/>
</operation></portType>
R.H. Mak PAGE 2727-9-2013
WSDL example: binding element
<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 … />
</output>
</operation>
</binding>
R.H. Mak PAGE 2827-9-2013
WSDL example: service element
<service name="Hello_Service">
<documentation>WSDL File for HelloService </documentation>
<port binding="tns:Hello_Binding" name="Hello_Port">
<soap:address
location="http://www.examples.com/SayHello/">
</port>
</service>
R.H. Mak PAGE 2927-9-2013
WSDL message exchange patterns
R.H. Mak PAGE 3027-9-2013
Name
In-Out
In-Only
Robust In-Only
Out-In
Out-Only
Robust Out-Only
Client Server Delivery Fault message
Request Reply may replace Reply
Request no fault message
Request guaranteed may be sent
Reply Request may replace Reply
Request no fault message
Request guaranteed may send fault
Messages sent by
Instructor’s Guide for Coulouris, Dollimore, Kindberg and Blair, Distributed Systems: Concepts and Design Edn. 5 © Pearson Education 2012
WADL
Web Application Description language
• Suitable to describe ReSTful Web services
• Definition and examples on following slides taken from
• http://www.w3.org/Submission/wadl/
• Not a formal W3C standard
• This document does not mention ReST, but refers to”
“HTTP-based applications that provide programmatic access to their internal data”
• A similar description language is the Atom Publishing Protocol
• more dedicated, however, to a specific application domain
R.H. Mak PAGE 3127-9-2013
WADL: document structure
<application>
<grammars>
definitions of data formats … [optional]
</grammars>
<resources base=“…”>
specifies the base URI
defines a list of resources
<resource>
definition of an individual resource
</resource>
</resources>
</application>
R.H. Mak PAGE 3227-9-2013
WADL example: resources element
<resources base="http://example.com/">
<resource path="widgets">
<resource path="reports/stock">
<param name="instockonly" style="matrix" 5 type="xsd:boolean"/>
...
</resource>
<resource path="{widgetId}">
</resource>
</resource>
<resource path="accounts/{accountId}">
...
</resource>
</resources>
R.H. Mak PAGE 3327-9-2013
WADL example: resources element
The <resources> element on the previous slide describes
• A resource identified by a static URI:
• http://example.com/widgets
• A resource identified by a static URI:
• http://example.com/widgets/reports/stock
• A resource identified by a matrix URI:
• http://example.com/widgets/reports/stock;instockonly
• Multiple resources identified by generative URIs:
• http://example.com/widgets/widgetId,
• where widgetId is replaced at runtime with the value of a runtime parameter called widgetId.
• Multiple resources identified by generative URIs:
• http://example.com/accounts/accountId, where …
R.H. Mak PAGE 3427-9-2013
<resources base="http://example.com/widgets">
<resource path="{widgetId}">
<param name="customerId" style="query"/>
<method name="GET">
<request>
<param name="verbose" style="query" type="xsd:boolean"/>
</request>
<response>
...
</response>
</method>
</resource>
</resources>
RESTful query using HTTP GET
R.H. Mak PAGE 3527-9-2013
http://example.com/widgets/123456?customerId=cust1234&verbose=true
correspondence
parameter value
widgetId 123456
customerId cust134
Verbose true
global for all methods
of this resource
local to the GET method
Example: query to determine the response mediaType
<method name="GET">
<request>
<param name="format" style="query">
<option value="xml" mediaType="application/xml"/>
<option value="json" mediaType="application/json"/>
</param>
...
</request>
<response>
<representation mediaType="application/xml"/>
<representation mediaType="application/json"/>
</response>
</method>
R.H. Mak PAGE 3627-9-2013
Agenda
• Introduction
• Web services technologies
• Orchestration
• Replication
R.H. Mak PAGE 3727-9-2013
Orchestration and choreography
Orchestration
• Pertains to lifecycle management of a (service-oriented) application
• Requires active party (the orchestrator) to control that lifecycle
− Instantiation, binding, activation, monitoring, (re)-configuration, …
− Implement policies
Choreography
• Pattern of service interaction resulting from a set of rules (or the set of rules itself
• Occurs spontaneously, between services themselves
− only the rules are provided
R.H. Mak PAGE 3827-9-2013
For a discussion see: http://www.infoq.com/news/2008/09/Orchestration
Example: FLUENT framework
Orchestrator
1
Orchestrator
2
Resource
manager
Component
Repository
Device
managerDevice
manager
Component
1
Component
3
Component
4
Component
2
Host 1
Host 2
Component
5
Device
manager
Host 3
R.H. Mak PAGE 3927-9-2013
Example taken from: R.H. Mak, Resource-aware Life Cycle Models for Service-oriented Application managed by a component Framework
Exampe: FLUENT Life Cycle
R.H. Mak PAGE 4027-9-2013
[deploy]
allocate hosts
assign modes
reserve resources
[success]
[non-feasible]
[redesign]
failure
instantiate
components
bind
interfaces
operateredesign
[redeploy]
[stop]
(1) (2)
(4)
install
components
[all installed]
[otherwise]
(2)
(3)
(Re-)Design (Re-)Deployment Operation
compose
application
[new design]
allocate
component
types
[partial]
[total]
define
location
constraints
define
resource
constraints
[stop]
[recompose]
[reallocate]
failure deploy
[finish]
[redesign]
define
reconfiguration
strategies
(1)
(2)
(3)
[recompose]
activate
components
execute
recover
error
deactivate
affected
components
Adapt
QoS
deallocate
affected
components
[operate]
[control cmd]
[all activated]
[otherwise] [RM 3 applies]
[non fatal]
[otherwise]
[error]
[other error] [resource conflict]
[fatal]
redesign redeployfailure
determine
Recovery
Mechanism
renegotiate
resource
reservations
deactivate
affected
components
[otherwise]
[RM 1 applies]
[RM 1or 2 applies]
(1)
Example: Service –oriented virtual community
R.H. Mak PAGE 4127-9-2013
Example: Service –oriented virtual community
R.H. Mak PAGE 4227-9-2013
Example taken from: Shudong Chen, J.J. Lukkien, A service-oriented virtual community overlay network for secure external service orchestration
Agenda
• Introduction
• Web services technologies
• Orchestration
• Replication
R.H. Mak PAGE 4327-9-2013
Server clusters
PAGE 4427-9-2013R.H. Mak
Server clusters (TCP-hand-offf)
PAGE 4527-9-2013R.H. Mak
• Web server uses IP-spoofing
• Selection of webserver by FE based on server load, not on
content of the request
Server clusters
PAGE 4627-9-2013R.H. Mak
Client-side caching / proxy servers
R.H. Mak PAGE 4727-9-2013
Origin server
Squirrel webcache
• Local caches in web browsers of clients in a single LAN are used to implement a distributed LAN-based web-server proxy.
• Can handle corporate networks from 100-100,000 nodes or more.
• Alternative for (a cluster of) web-proxy servers
• Uses a peer-to-peer architecture (overlay) on the LAN
• Built on top of Pastry, but any P2P routing overlay will do.
• Inserts a squirrel proxy between the browser and the local web cache.
• Uses HTTP conditional GET
• Scales horizontally and automatically
• As the number of browsers increases so does the cache capacity, whereas cache response time stays almost constant.
• No administrative effort required.PAGE 4827-9-2013R.H. Mak
Home-store scheme
PAGE 4927-9-2013R.H. Mak
Sitaram lyer, Antony Rowstron, and Peter Druschel, Squirrel: A decentralized peer-to-peer web cache
Directory scheme
PAGE 5027-9-2013R.H. Mak