distributed systems 2006 web services (with material from [møller & schwartzbach, 2003])

40
Distributed Systems 2006 Web Services (With material from [Møller & Schwartzbach, 2003])

Post on 20-Dec-2015

219 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Distributed Systems 2006 Web Services (With material from [Møller & Schwartzbach, 2003])

Distributed Systems 2006

Web Services

(With material from [Møller & Schwartzbach, 2003])

Page 2: Distributed Systems 2006 Web Services (With material from [Møller & Schwartzbach, 2003])

Distributed Systems 2006 2

Plan

  Basics– SOAP– WSDL– UDDI

  Related specifications

Page 3: Distributed Systems 2006 Web Services (With material from [Møller & Schwartzbach, 2003])

Distributed Systems 2006 3

A Web Service

  A software system designed to support interoperable machine-to-machine interaction over a network– It has an interface described in a machine-

processable format (specifically WSDL)– Other systems interact with the Web service in a

manner prescribed by its description using SOAP messages

– These are typically conveyed using HTTP with an XML serialization in conjunction with other Web-related standards

  [W3C]

Page 4: Distributed Systems 2006 Web Services (With material from [Møller & Schwartzbach, 2003])

Distributed Systems 2006 4

Motivation

  Heterogeneous, distributed systems– Scalability– Interoperability– Modifiability

  The main motivation is interoperability– The ability for separately developed applications to

work in together

Page 5: Distributed Systems 2006 Web Services (With material from [Møller & Schwartzbach, 2003])

Distributed Systems 2006 5

SOAP, SOAP, UDDI

  SOAP– A framework for exchanging XML-based information in a network– SOAP used to be an acronym: Simple Object Access Protocol– "This is no longer the case." (it is neither simple nor has anything to do

with objects)– The currently most hyped XML/Web service technology

  WSDL (Web Service Description Language)– An XML-based language for describing network services– WSDL descriptions of capabilities and locations of services– Like an Interface Description Language for Web services– Often communication using SOAP + HTTP

  UDDI (Universal Description, Discovery, and Integration)– Provides a registry mechanism for clients and servers to find each other– Uses SOAP for communication

Page 6: Distributed Systems 2006 Web Services (With material from [Møller & Schwartzbach, 2003])

Distributed Systems 2006 6

Backupserver

Primary server Legacy

system

web services

Externalsystem

web services

(web services)

(web services)

Page 7: Distributed Systems 2006 Web Services (With material from [Møller & Schwartzbach, 2003])

Distributed Systems 2006 7

An Example

Page 8: Distributed Systems 2006 Web Services (With material from [Møller & Schwartzbach, 2003])

Distributed Systems 2006 8

A Result

Page 9: Distributed Systems 2006 Web Services (With material from [Møller & Schwartzbach, 2003])

Distributed Systems 2006 9

SOAP RequestMessage transport

Message intent

Message contents

Application data

Page 10: Distributed Systems 2006 Web Services (With material from [Møller & Schwartzbach, 2003])

Distributed Systems 2006 10

SOAP Response

Page 11: Distributed Systems 2006 Web Services (With material from [Møller & Schwartzbach, 2003])

Distributed Systems 2006 11

org.apache.axis.utils.tcpmon

  Part of Apache Axis toolset

Page 12: Distributed Systems 2006 Web Services (With material from [Møller & Schwartzbach, 2003])

Distributed Systems 2006 12

Anatomy of SOAP

  Lightweight, stateless protocol framework for exchanging XML messages– Applications can create complex interaction patterns

• Request/response• Request/multiple responses• ...

– by combining one-way exchanges with features provided by an underlying protocol and/or application-specific information

  Silent on the semantics of any application-specific data it conveys

  Message contents– xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/”

• soapenv:Envelope– soapenv:Header

» Application-specific control information» May be processed by intermediaries

– soapenv:Body» Information exchanged between sender and receiver

  Typical protocols– HTTP– SMTP

Page 13: Distributed Systems 2006 Web Services (With material from [Møller & Schwartzbach, 2003])

Distributed Systems 2006 13

  (Really, the Google search API is a bad example of a web service design– E.g., http://www.prescod.net/rest/googleapi/

  But has its merits, e.g., in interaction with other web services)

Page 14: Distributed Systems 2006 Web Services (With material from [Møller & Schwartzbach, 2003])

Distributed Systems 2006 14

WSDL

  WSDL is an XML-based language that allows formal descriptions of the interfaces of Web services– which interactions does the service provide?– which arguments and results are involved in the interactions?– which network addresses are used to locate the service?– which communication protocol should be used?– which data formats are the messages represented in?

  So what are the benefits?– an interface description is a contract between the server

developers and the client developers– having formal descriptions allows tool support, e.g. code

template generators

Page 15: Distributed Systems 2006 Web Services (With material from [Møller & Schwartzbach, 2003])

Distributed Systems 2006 15

A WSDL Example (1)

Page 16: Distributed Systems 2006 Web Services (With material from [Møller & Schwartzbach, 2003])

Distributed Systems 2006 16

A WSDL Example (2)Data types defined using XML Schema

Message types definedfrom data types

Port type defining operations

Binding to SOAP RPCover HTTP

Port where the runningservice may be accessed

Page 17: Distributed Systems 2006 Web Services (With material from [Møller & Schwartzbach, 2003])

Distributed Systems 2006 17

WSDL Layers

  The language can be described as having two layers– the service definition layer describes abstract

properties:• data types• message types• operations• services

– The binding layer describes concrete properties:• Protocols• Data formats

(using SOAP, HTTP, MIME)

Page 18: Distributed Systems 2006 Web Services (With material from [Møller & Schwartzbach, 2003])

Distributed Systems 2006 18

WSDL Elements

  An actual WSDL document consists of a set of definitions of the following kinds:– types - containing XML Schema element and type definitions – message - consisting of either

• a number of named parts typed by XML Schema elements, or • a single part typed by a XML Schema type

– portType - describing a set of operations, each being either • one-way: receiving an input message, • request-response: receiving an input message and then responding with an

output message (like Remote Procedure Calls), • solicit-response: sending an output message and then receiving an input

message, or • notification: sending an output message

– binding - selects communication protocol and data formats for each operation and message

– service - describes a collection of named ports, each associated with a binding and a network address

  An import mechanism allows modularization of definitions.

Page 19: Distributed Systems 2006 Web Services (With material from [Møller & Schwartzbach, 2003])

Distributed Systems 2006 19

SOAP in WSDL

  The SOAP binding in WSDL:– selects document or rpc style (rpc wraps message

parts)– selects HTTP/SMTP/... protocol– selects encoding type

• Encoded – specifies data formats• Literal

– places message parts in header or body parts of the envelope

Page 20: Distributed Systems 2006 Web Services (With material from [Møller & Schwartzbach, 2003])

Distributed Systems 2006 20

Examples of style versus encoding

  public void myMethod(int x, float y); – RPC/Encoded

• <soap:envelope> <soap:body> <myMethod> <x xsi:type="xsd:int">5</x> <y xsi:type="xsd:float">5.0</y> </myMethod> </soap:body> </soap:envelope>

– RPC/Literal• <soap:envelope> <soap:body> <myMethod> <x>5</x> <y>5.0</y>

</myMethod> </soap:body> </soap:envelope> – (Document/Encoded)– Document/Literal

• <soap:envelope> <soap:body> <xElement>5</xElement> <yElement>5.0</yElement> </soap:body> </soap:envelope>

  WS-I Compliance– Tries to clean up to web service mess so that web services may actually

interoperate– Recommends RPC/Literal or Document/Literal

  (Why not use Document/Literal all the time?)

Page 21: Distributed Systems 2006 Web Services (With material from [Møller & Schwartzbach, 2003])

Distributed Systems 2006 21

Problems with WSDL

  The HTTP and MIME bindings are too loosely specified (so not all WSDL documents "make sense")

  WSDL is closely tied with SOAP– SOAP is big and complicated without offering very

much

  Complex interaction patterns cannot be described (e.g. transactions)

Page 22: Distributed Systems 2006 Web Services (With material from [Møller & Schwartzbach, 2003])

Distributed Systems 2006 22

Using Web Services with Java

  JAX-RPC (JSR-101)– Java API for XML-Based RPC

• Including WSDL <-> Java mapping – Apache AXIS (Apache Extensible Interaction System)

• http://ws.apache.org/axis/ • a Java-based implementation of SOAP + WSDL

– largely allows the programmer to forget these technologies• WSDL <-> Java• Used together with a servlet container such as Tomcat or Jetty

– Java Web Services Developer Pack  JAX-WS 2.0 (JSR-224)

– Java API for XML Web Services – was JAX-RPC 2.0– Heavy use of Java 5.0 annotations to customize mapping from WSDL and at

runtime– @WebService

@BindingType(value="http://www.w3.org/2003/05/soap/bindings/HTTP/")public class AddNumbersImpl {

– Similar to .NET, will (probably) be built into Java 6.0

Page 23: Distributed Systems 2006 Web Services (With material from [Møller & Schwartzbach, 2003])

Distributed Systems 2006 23

UDDI - Universal Description, Discovery, and Integration

  A Web service registry mechanism– "a meta service for locating Web services by enabling robust queries

against rich metadata"

  UDDI business registration: XML files used to describe business entities and their Web services– white pages - business address, contact info, etc.– yellow pages - industrial categorizations based on standard taxonomies

(allows search within particular industry, product category, geographical region, ...)

– green pages - more technical information, for instance WSDL descriptions

  UDDI also provides a SOAP+WSDL-based registry API for registering ("publish") and discovering ("inquire") Web services

  A UDDI browser: http://www.soapclient.com/uddisearch.html

Page 24: Distributed Systems 2006 Web Services (With material from [Møller & Schwartzbach, 2003])

Distributed Systems 2006 24

An Example

  <businessEntity businessKey="ba744ed0-3aaf-11d5-80dc-002035229c64"   operator="www.ibm.com/services/uddi"   authorizedName="0100001QS1">  <discoveryURLs>  <discoveryURL

useType="businessEntity">http://www.ibm.com/services/uddi/uddiget?businessKey=BA744ED0-3AAF-11D5-80DC-

002035229C64</discoveryURL>

  </discoveryURLs>  <name>XMethods</name>  <description xml:lang="en">Web services resource site</description>  <contacts>  <contact useType="Founder">  <personName>Tony Hong</personName>  <phone useType="Founder" />  <email useType="Founder">[email protected]</email>  </contact>  </contacts>  ...

Page 25: Distributed Systems 2006 Web Services (With material from [Møller & Schwartzbach, 2003])

Distributed Systems 2006 25

An Example

  <businessServices>  <businessService serviceKey="d5921160-3e16-11d5-98bf-002035229c64"   businessKey="ba744ed0-3aaf-11d5-80dc-002035229c64">  <name>XMethods Delayed Stock Quotes</name>  <description xml:lang="en">20-minute delayed stock quotes</description>  <bindingTemplates>  <bindingTemplate bindingKey="d594a970-3e16-11d5-98bf-002035229c64"   serviceKey="d5921160-3e16-11d5-98bf-002035229c64">  <description xml:lang="en">SOAP binding for delayed stock quotes service</description>  <accessPoint URLType="http">http://services.xmethods.net:80/soap</accessPoint>  <tModelInstanceDetails>  <tModelInstanceInfo tModelKey="uuid:0e727db0-3e14-11d5-98bf-002035229c64" />  </tModelInstanceDetails>  </bindingTemplate>  </bindingTemplates>  </businessService>  </businessServices>  </businessEntity>

Page 26: Distributed Systems 2006 Web Services (With material from [Møller & Schwartzbach, 2003])

Distributed Systems 2006 26

UDDI Elements

  A UDDI businessEntity describes a business and its services– Key attributes locate various data structures – a businessService describes a particular service (or family of services) – a bindingTemplate describes where and how a service is accessed – a tModel describes compliance with a specification (e.g. a WSDL description)

  This tModel for the single service described above refers to bindings in a WSDL description:

  <tModel tModelKey="uuid:0e727db0-3e14-11d5-98bf-002035229c64"  operator="www.ibm.com/services/uddi"  authorizedName="0100001QS1">  <name>XMethods Simple Stock Quote</name>  <description xml:lang="en">Simple stock quote interface</description>  <overviewDoc>  <description xml:lang="en">wsdl link</description>  <overviewURL>http://www.xmethods.net/tmodels/SimpleStockQuote.wsdl</overviewURL>  </overviewDoc>  <categoryBag> <keyedReference tModelKey="uuid:c1acf26d-9672-4404-9d70-

39b756e62ab4” ... </categoryBag>  </tModel>

  the WSDL document has no service part - the service address is specified in the bindingTemplate

  UDDI is much more general (and more complicated) than these examples suggest...

Page 27: Distributed Systems 2006 Web Services (With material from [Møller & Schwartzbach, 2003])

Distributed Systems 2006 27

SOAP to UDDI

  The following SOAP message could be sent to a UDDI registry to inquire about services named "delayed stock quotes":

  <?xml version="1.0" encoding="UTF-8"?>  <Envelope

xmlns="http://schemas.xmlsoap.org/soap/envelope/">  <Body>  <find_service businessKey="*" generic="1.0"

xmlns="urn:uddi-org:api">  <name>delayed stock quotes</name>  </find_service>  </Body>  </Envelope>

– Alternatively, we could search by category codes of various kinds– The find_service meta-service operation is specified in the WSDL for the UDDI

API– Of course, the UDDI registries are also registered services :-)

Page 28: Distributed Systems 2006 Web Services (With material from [Møller & Schwartzbach, 2003])

Distributed Systems 2006 28

Sidetrack: SOA

  Service-Oriented Architecture– Practices and technology that enable application

functionality to be provided and consumed as services

– Services can be invoked, published and discovered, and are abstracted away from the implementation using a single, standards-based form of interface.

  Resources– http://www.cbdiforum.com– http://www.google.com/search?q=oasis+soa

Page 29: Distributed Systems 2006 Web Services (With material from [Møller & Schwartzbach, 2003])

Distributed Systems 2006 29

SOA and Web Services

  SOA is not equivalent to web services– Other possible underlying technologies

J2EE/CORBA, .NET, …

  Concepts map well to web services

Page 30: Distributed Systems 2006 Web Services (With material from [Møller & Schwartzbach, 2003])

Distributed Systems 2006 30

SOA Concepts

  Service– Contractually defined behavior– Implemented and provided by a component,

used by another component– Web services

• Maps to a web service

  Service descriptions– Each service should include a service

description in standardized format– Technical parameters, constraints, and

policies that define the terms to invoke the service

– Web services• Maps to a WSDL description of a web service

  Advertising and discovery– Services should be able to be discovered– Services need to be advertised to be

discovered– Web services

• May be provided by a UDDI repository

  Data model– Invoker and invokee need to have a common

conception of data– Web services

• XML Schemas may define data as used by services

Page 31: Distributed Systems 2006 Web Services (With material from [Møller & Schwartzbach, 2003])

Distributed Systems 2006 31

Internal: Service Layer

  Defines an application’s boundary with a layer of services that establishes a set of available operations and coordinates the application’s response in each situation

Page 32: Distributed Systems 2006 Web Services (With material from [Møller & Schwartzbach, 2003])

Distributed Systems 2006 32

Internal: Services

  Service guidelines– Self-contained – coarse-grained functionality– “Stateless” – should not retain client state between

invocations– Context-independence – should not depend on other

services

Page 33: Distributed Systems 2006 Web Services (With material from [Møller & Schwartzbach, 2003])

Distributed Systems 2006 33

External: Architecture

  Service-Oriented Architecture does not define a software architecture per se– ”… the structure or structures of [a] system, which

comprise software elements, the externally visible properties of those elements, and the relationships among them” [Bass et al., 2003]

  Interaction among services still need to be designed at an architectural level

Page 34: Distributed Systems 2006 Web Services (With material from [Møller & Schwartzbach, 2003])

Distributed Systems 2006 34

External: Deutsch’s Eight Fallacies of Distributed Computing

  1. The network is reliable  2. Latency is zero  3. Bandwidth is infinite  4. The network is secure  5. Topology doesn't change  6. There is one administrator  7. Transport cost is zero  8. The network is homogeneous

Page 35: Distributed Systems 2006 Web Services (With material from [Møller & Schwartzbach, 2003])

Distributed Systems 2006 35

Seven Fallacies of SOA

  Fallacy #1– There's Nothing New Under the Sun, and SOA Is No Exception

  Fallacy #2– SOA is a Revolutionary Paradigm Shift

  Fallacy #3– SOAs are All Hype, No Substance

  Fallacy #4– SOA is a Panacea

  Fallacy #5– The Overhead from SOA Leads to Unacceptably Poor Performance

  Fallacy #6– A Bottom-Up Approach to SOA is Good Enough

  Fallacy #7– SOA is Optional

  http://www.zapthink.com/report.html?id=ZAPFLASH-08052004

Page 36: Distributed Systems 2006 Web Services (With material from [Møller & Schwartzbach, 2003])

Distributed Systems 2006 36

FastWS

  Application are unaware of which protocol they use– Implementations may serve XML and Fast concurrently

– http://java.sun.com/developer/technicalArticles/WebServices/fastWS/

Page 37: Distributed Systems 2006 Web Services (With material from [Møller & Schwartzbach, 2003])

Distributed Systems 2006 37

The Web Service Stack

Page 38: Distributed Systems 2006 Web Services (With material from [Møller & Schwartzbach, 2003])

Distributed Systems 2006 38

Status of the Stack

Page 39: Distributed Systems 2006 Web Services (With material from [Møller & Schwartzbach, 2003])

Distributed Systems 2006 39

Summary

  Web services– Machine-to-machine interaction over a network– Typically WSDL + SOAP + HTTP

  A large number of supporting specifications

Page 40: Distributed Systems 2006 Web Services (With material from [Møller & Schwartzbach, 2003])

Distributed Systems 2006 40

References

  [Møller & Schwartzbach, 2003]– Møller, A., and Schwartzbach, M. (2003). Interactive

Web Services with Java. http://www.brics.dk/~amoeller/WWW, accessed 2006-02-14