What are Web Services? - Connect
Transcript of 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
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
Outline Definition of Web Services
Why Web Services? – Motivation
Interaction Styles Web Service Architecture and Core Technologies
SOAP, WSDL, UDDI
The case of REST
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)
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
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?
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
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
An example application
Calendar on PDA9pm:Reservation atParisrestaurant Restaurant
WebService
HotelWeb
Service
AirlineWeb
Service
Grand Hotel
Ibis Hotel
British Airways
EasyJet
Air France
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
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)
Remote Procedure CallInteractive Order request/response
Document Oriented InteractionWorkflow of purchase order
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
Example: Combining Services Google Maps + craigslist rentals= housingmaps.com
16
WS architecture
serviceprovider
servicerequester
Serviceregistry
4. bind and invoke
3. discover (+ discover
and compose)2. publish (+ compose
and publish)
(1. describe)
UDDI
WSDL
SOAP
XML
WS Core Technologies
Discovery
Description
Interaction
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
Example XML
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
An Abstract Comm. Protocol
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...
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
WSDL Elements
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)? ...
<?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
<?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
<?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
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
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
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
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
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
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)
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
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
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)
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
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
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
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