Web Services
Web Services
26 November 2013
Katrien Verbert
Natasha Stash
George Fletcher
Plan for today
PAGE 4
Recap: Web Fundamentals
PAGE 5
URIs / resources
PAGE 6
Resource representation
PAGE 7
Plan for today
PAGE 8
APIs
What is an API?
and
PAGE 9
(Web) APIs
PAGE 10
Web Services, Web Applications and
APIs (Application Programming Interface)
PAGE 11
Web Services, Web Applications and
APIs (Application Programming Interface)
PAGE 12
Web Services
PAGE 13
Web Services
Example operations:
Publish image on Flickr
Order a book at Amazon
Post a message on your friends Facebook wall
PAGE 14
What Are Web Services?
PAGE 15
Example client application
http://ariadne.cs.kuleuven.be/alocom/alocom_plugin/alocom_plugin.swf
PAGE 16
PAGE 17
Disaggregation service
PAGE 18
What Are Web Services?
W3C definition:
A software system designed to support
interoperable machine-to-machine interaction over a
network...
PAGE 19
Web Services Use
PAGE 20
Major classes of Web Services
Big Web Services (L. Richardson and S. Ruby)
RESTful (REST-compliant) Web Services
PAGE 21
PAGE 22
PAGE 23
Overview
Introduction
RESTful services
SOAP-based services
Comparison
Tutorial
JAX-WS: Building SOAP-based services in Java
JAX-RS: Building RESTful services in Java
PAGE 24
A RESTful Web service...
... exposes its data and functionality through
interlinked Web resources identified by URI.
PAGE 26
Use HTTP methods explicitly
PAGE 27
Example: HTTP GET request
PAGE 28
Example: HTTP PUT request
PAGE 29
Be stateless
Stateful design
Stateless design
PAGE 30
Expose directory structure-like URIs
http://www.myservice.org/discussion/topics/{topic}
http://www.myservice.org/discussion/{year}/{day}/{month}/{topic}
http://www.myservice.org/discussion/2008/12/10/{topic}
PAGE 31
Transfer XML, JSON, or both
<?xml version="1.0"?>
<discussion date="{date}" topic="{topic}">
<comment>{comment}</comment>
<replies>
<reply from="[email protected]" href="/discussion/topics/{topic}/joe"/>
<reply from="[email protected]" href="/discussion/topics/{topic}/bob"/>
</replies>
</discussion>
PAGE 32
Tools and frameworks
PAGE 33
Overview
Introduction
Restful services
Big web services
Comparison
Tutorial
JAX-WS: Building SOAP-based services in Java
JAX-RS: Building RESTful services in Java
PAGE 34
Big web services
PAGE 35
Roadmap
Service
Broker
(UDDI)
Find Publish
(SOAP) (WSDL)
Service Service
Requester Provider
Bind
(SOAP)
PAGE 36
What is SOAP
PAGE 37
SOAP Message Structure
<env:Body>
SOAP Body ...
<env:Fault>
body block ...
</env:Fault>
</env:Body>
</env:Envelope>
PAGE 38
SOAP Example: RPC-Style Request Message
<?xml version='1.0' ?> Request
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
<env:Body>
<ts:getPrice xmlns:ts="http://travelagency.example.org/wsdl/trips"
s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding">
<ts:departing>Amsterdam (Schiphol)</ts:departing>
<ts:arriving>Saint-Petersburg (Pulkovo)</ts:arriving>
<ts:departureDate>01-05-2010</ts:departureDate>
<ts:/getPrice>
</env:Body>
</env:Envelope>
PAGE 41
Roadmap
Service
Broker
(UDDI)
Find Publish
(SOAP) (WSDL)
Service Service
Requester Provider
Bind
(SOAP)
PAGE 42
What is WSDL
PAGE 43
WSDL
PAGE 44
WSDL Document Structure
WSDL Specification
abstract part Main structure of WSDL document
types <definitions targerNamespace= ... >
messages
<types>definition of types...</types>
operations
<message>definition of a message...</message>
port types
<portType>definition of a port</portType>
concrete part
<binding>definition of a binding...</binding>
bindings
<service>
service
<port>...</port>
port </service>
</definitions> PAGE 45
WSDL Document Example:
Abstract Part
<message name="itineraryMsg">
<part name="departing" type="xs:string"/>
<part name="arriving" type="xs:string"/>
<part name="departureDate" type="xs:date"/>
</message>
<message name="itineraryRespMsg">
<part name="price" type="xs:string"/>
</message>
<portType name="pricesPT">
<operation name="getPrice">
<input message="itineraryMsg"/>
<output message="itineraryRespMsg"/>
</operation>
</portType> PAGE 46
Operation Types
Type Definition
One-way The operation can receive a message but will not return
a response
Solicit-response The operation can send a request and will wait for a
response
Notification The operation can send a message but will not wait for
a response
PAGE 47
Example: One-Way Operation
<message name="newPrices">
<part name="departing" type="xs:string"/>
<part name="arriving" type="xs:string"/>
<part name="departureDate" type="xs:date"/>
<part name="price" type="xs:string"/>
</message>
<portType name="pricesPT">
...
<operation name="setPrice">
<input message="newPrices"/>
</operation>
</portType >
PAGE 48
WSDL Document Example:
Concrete Part
<service name="pricesService">
<port name="getPriceRPCPort" binding="ts:b1">
<soap:address
location="http://travelagency.example.org/pricesService">
</port>
</service>
xmlns:ts='http://travelagency.example.org/wsdl/trips'
PAGE 49
Roadmap
Service
Broker
(UDDI)
Find Publish
(SOAP) (WSDL)
Service Service
Requester Provider
Bind
(SOAP)
PAGE 50
What is UDDI
PAGE 51
Ways to Use UDDI Registry
White pages
name, address, contact person, Web site
Yellow pages
types of business, locations, products, services,
categorizations
Green pages
technical information about business services, pointers
to WSDL descriptions of the services
PAGE 52
UDDI Data Model:
UDDI Core Data Types
PAGE 54
UDDI: Programmatic Interfaces
PAGE 55
Big Web Services Examples
http://www.xmethods.com
http://www.programmableweb.com/
PAGE 56
Web services enable
PAGE 57
Which of the following is used to locate
and describe web services?
1. SOAP
2. Web page
3. WSDL
4. UDDI
PAGE 58
Overview
Introduction
Restful services
SOAP-based services
Comparison
Tutorial
JAX-WS: Building SOAP-based services in Java
JAX-RS: Building RESTful services in Java
PAGE 59
Big Web Service Operations vs
RESTful Web Service URIs
getAllUsers() http://example.com/users/
"
getUserById(String id) http://example.com/users/id/{user-id}
getUserByName(), http://example.com/users/name/{user-name}
addUser()
removeUser(),
updateUser()
PAGE 60
Big Web Services versus REST
PAGE 61
Comparison:
Big Web Services vs RESTful Web Services
Big Web Services pros:
protocol transparency and independence
existence of tools to hide the complexity
security
PAGE 62
Comparison:
Big Web Services vs RESTful Web Services
RESTful Web Services pros:
simplicity
lightweight infrastructure
addressability
uniform interface
scalability of stateless RESTful Web Service
improved performance using JSON
PAGE 64
[email protected]
[email protected]
[email protected]
PAGE 65