Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
1
The
Web Paradigm Shift
The Heretical Guide to Designing Web Services
by
Roger L. Costello and Timothy D. Kehoe
Last Updated: May 20, 2006
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
2
CONTENTS
1.
2.
3.
4.
5.
6.
7.
8.
Web Basics
The Web Paradigm Shift
7 Laws of Web Service Design
Case Study: Implementing Priorities
Logical URLs, Physical URLs, Resources and Representations
Links and the Structure of Knowledge
Guidance, Do's and Don'ts
7.1 Net-centric XML
7.2 "Getting Information" versus "Doing Things"
7.3 Characterizing Good Web Services
7.4 Characterizing Good Web Documents
Closing Remarks
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
3
What is a Web Service?
A Web Service is a software implementation
of a resource, identified by a URL, reached
using internet protocols.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
4
Web Basics*
* For an excellent introduction to Web basics, check out this book:
HTTP Essentials by Stephen Thomas from Wiley Computer Publishers.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
5
The Web
information
information
information
information
The Web is a network of information
that can be traversed in many ways.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
6
Paths to
Information
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
7
What’s in a Name?
http://www.cnn.com/2006/01/11/implosion.ap/index.html
The resource that we are after.
The host that holds what we want.
The scheme identifies the protocol that is to be used; in this
example, the HyperText Transfer Protocol.
There are 51 other schemes, among them
- https (HyperText Transfer Protocol Secure)
- ftp (File Transfer Protocol)
- urn (Uniform Resource Names)
HTTP (version 1.1) is by far the most commonly used scheme.
For all practical purposes, HTTP 1.1 is the "Web Protocol."
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
8
The Web API
• HTTP provides a simple set of operations.
Amazingly, all Web exchanges are done
using this simple HTTP API:
–
–
–
–
GET = "give me some stuff" (Retrieve)
POST = "here's some better stuff" (Update)
PUT = "here's some new stuff" (Create)
DELETE = "delete that stuff" (Delete)
• A few simple rules allow you to create
tremendous complexity.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
9
Retrieving Information
1
Client
Server
GET URL
data + status code
2
The server responds with, not only the data (the Web
page), but also a result code (200 means everything is OK)
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
10
HTTP GET
http://www.cnn.com/US_News
GET /US_News HTTP/1.1
Host: www.cnn.com
CNN Server
- The user types in at his browser: http://www.cnn.com/US_News
- The browser software creates an HTTP header
- The HTTP header identifies:
- The desired action: GET ("get me some stuff")
- The target machine (www.cnn.com)
- The resource (US_News)
- The version of HTTP being used (version 1.1)
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
11
Updating Information
1
Client
Server
POST URL + data
data + status code
2
The client provides information. The server responds
with a result code (200 means everything is OK)
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
12
Change of Address Form
HTTP POST
Street: 91 Tremont St.
City:
Boston
POST /customer/john_doe/address HTTP/1.1
Host: www.chase.com
State: MA
Zip:
01710
SUBMIT
Street Address: 91 Tremont St.
City: Boston
State: MA
Zipcode: 01710
Chase Server
• The user fills in the Web page's form (Chase Bank's Change of Address Form)
• The browser software creates an HTTP header, and a payload which
is comprised of the form data
- The HTTP header identifies:
- The desired action: POST ("here's my new address")
- The target machine (www.chase.com)
- The resource (customer/john_doe/address)
- The payload contains:
- The data being POSTed (the form data)
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
13
Providing Information
1
Client
Server
PUT URL + data
data + status code
2
POST is used to update existing information on the server.
PUT is used to make new information available on the server.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
14
Removing Information
1
Client
Server
DELETE URL
data + status code
2
The client requests that the server remove information
identified by the URL. Typically a server will return an
acknowledgement that it has deleted the requested data.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
15
Basic Web Components
• Firewalls and Proxy Filters: these components
decide what HTTP messages get out, and what get in.
– These components enforce Web security.
• Routers: these components decide where to send
HTTP messages.
– These components manage Web scaling.
• Caches: these components decide if a saved copy can
be used.
– These components increase Web speed.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
16
Firewalls and Proxy Filters
POST /personals/SallysPornShop HTTP/1.1
Host: www.geocities.com
Item: Sally in lingerie
Credit Card: Visa
Number: 1234-5678-9012-6789
Expiry: June 2006
Item: Sally in lingerie
Credit Card: Visa
Number: 1234-5678-9012-6789
Expiry: June 2009
– The proxy filter decides whether an
HTTP message should pass
– This message is rejected!
PROXY FILTER
("Should I allow POSTing to SallysPornShop?")
Proxy Filter Rules & Policies
Prohibit all POSTs to the
SallysPornShop Web site.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
17
Routers
Source host
PC
Packet
To: Destination host (Protocol address)
Router 1
(Physical address)
Packet
Router 1
To: Destination host (Protocol address)
Router 2
(Physical address)
Router 2
To: Destination host (Protocol address)
Router 3
(Physical address)
Router 3
Packet
To: Destination host (Protocol address)
Destination host (Physical address)
Destination host
PC
Packet
http://www.cisco.com/univercd/cc/td/doc/cisintwk/ito_doc/routing.html
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
18
Caches
2
1
First access, goes
all the way back
to the server with
the data (origin
server)
GET
GET
Server
Cache
Client
data + status code
4
data + status code
3
5
Next access, the
cache returns
the data.
GET
Cache
Client
data + status code
6
Server
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Proxy Filters and Caches Operate
using only Information found in
the HTTP Header!
HTTP Header
HTTP Payload
Component
(proxy filter, cache)
Web Message
Firewalls and routers use lower-level information, such as IP addresses.
19
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
20
Header and Payload
Change of Address Form
Street: 91 Tremont St.
City:
Boston
This information
(the HTTP data)
is called the
HTTP header
POST /customer/john_doe/address HTTP/1.1
Host: www.chase.com
State: MA
Zip:
01710
SUBMIT
Street Address: 91 Tremont St.
City: Boston
State: MA
Zipcode: 01710
Chase Server
This information (the form data) is called the payload.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
21
Reasons for Basing Decisions
Solely on the HTTP Header
• The content of the HTTP header is well-defined
(standard semantics).
• Conversely, the HTTP payloads change from request
to request.
• Web components cannot make sense of all the
different kinds of information that may occur in
payloads.
Web components never peek inside the message payload.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
22
Summary
•
•
•
•
The web is all about information sharing.
URL’s identify information on the Web.
HTTP is the predominate protocol on the Web.
HTTP provides a very simple API:
– GET, POST, PUT, DELETE
• The Web's basic components operate by
examining the HTTP header
– Firewalls, proxy filters, caches, routers
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
23
The Web Paradigm Shift
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
24
"The Web is a paradigm shift"
- Tim Berners-Lee, W3C Chairman
Symposium, Nov. 2005
What is a paradigm shift?
What is the paradigm shift that he refers to?
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
25
Scientific progress has not been a
steady, forward movement toward
knowledge.
Better characterized as a series of
peaceful interludes punctuated by
intellectually violent revolutions
(Copernicus, Darwin, Freud).
In time, and with difficulty, a new
conceptual view replaces the old.
When the new framework replaces
the old, we look at the world through
the context of this new framework.
We reframe the problems and pose
new solutions using new tools.
This is when a paradigm shift occurs.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
26
Programming Paradigm Shift
• Structured programming first appeared with
ALGOL in ~1960
– emphasized a top-down approach to coding algorithms,
– divided a program into "intellectually manageable
programs" [Dijkstra],
– employed limited control structures that repeatedly
invoke subtasks in the form of subroutines.
• Structured programming was a paradigm shift
meant to correct disorganized programming
practices endemic in assembly-level
programming.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
27
Programming Paradigm Shift
• Object-oriented programming began in
1980 with Smalltalk and the dawning of the
OO methodology
– emphasized data and its state, wrapped in an object,
– manipulated object state through messaging,
– defined relations through inheritance.
• Object-oriented programming was a paradigm
shift meant to add data management to the
practices inherited from procedural programming.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
28
Programming Paradigm Shift
• Web programming challenges us to make
still another paradigm shift
–
–
–
–
model information as resources identified by URLs
implement tasks through the exchange of information
link to information rather than embed information
create loose networks of information rather than rigid
taxonomies
– traverse information in user-defined ways, rather than
through preset paths
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
29
The Web Paradigm:
Information Exchange
•
•
•
•
GET: "give me some information"
POST: "here's some updated information"
PUT: "here's some new information"
DELETE: "delete that information"
information
Server
What "actions" the server performs
to generate the output information
are opaque to the client.
Client
information
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
30
The Web Paradigm: a Network of
Linked Information
The latest news
in Iraq is not good.
Five more US army
...
Observe that the information can come
in many different formats - text, audio,
video, and others.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
31
Summary
• The Web paradigm is one of
– exchanging information with a resource identified by a
URL
– linking to information, rather than embedding
information
– traversing information in user-defined ways, rather than
through preset paths
– networks of information rather than neat taxonomies
• The Web is a collection of highly
interconnected information, that may be
processed in many different ways.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
32
7 Laws of Web Service Design
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
33
7 Laws of Web Service Design
1. Resources: Primal Elements of the Web
2. URLs: Identify every Resource
3. Content Types: Adaptability and Survival on the Web
4. Information Exchange: Trade Documents, not Arguments
5. Links: Connect, don't Encapsulate
6. Payload versus Protocol: The Right Information in the Right Place
7. Viewpoints: Information from Any Perspective, in any Direction
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
34
Resources
Primal Elements of the Web
• Resources are the basic building blocks of the
Web.
• Every activity on the Web is one of Creating,
Retrieving, Updating and Deleting (CRUD)
resources.
• A resource is a conceptual entity.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
35
A Resource is a Conceptual Entity
• Consider "information". It is an abstract,
conceptual thing. It is concretely "represented" in
many different forms - in text form, in audio form,
in pictorial form.
• Likewise, a resource is an abstract, conceptual
thing. It is concretely "represented" in many
different forms - in HTML form, in XML form, in
MP3 form, in MPEG form.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
36
Identifying Resources
• Identify the resources in the below
description of the Boston airport.
• The resources are:
–
–
–
–
–
The Boston airport, BOS
Airplane with tail number FX12
Airplane with tail number BA99
Route BOS-LAX
Route BOS-ALT
The Boston airport (BOS) has these airplanes (tail number):
FX12 and BA99. FX12 flies this route: BOS-LAX. BA99 flies
this route: BOS-ALT.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
37
Boston Airport Resources
BOS
BA99
FX12
BOS-ALT
BOS-LAX
Note: a circle is used
to depict a resource
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
38
URLs
Identify every Resource
• The Web is all about resources. If you can't
address a resource, you can't do anything with
it!
• Law: Identify each resource with a URL.
• This law is fundamental to the Web that Tim
Berners-Lee calls it Web Design, Axiom 0.
• Benefits:
– Individually reachable resources are discoverable
by search engines (think Google).
– Individual resources may have individualized
metadata for cataloging.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
39
Web Design, Axiom 0
(Tim Berners-Lee, director of W3C)
• Axiom 0: all resources on the Web must be
uniquely identified with a URI.
URL1
resource1
URL2
resource2
URL3
resource3
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
40
Identify the Airport Resources
with URLs
http://www.airportInc.com/airport/bos
BOS
http://www.airportInc.com/airport/bos/airplane/ba99
BA99
http://www.airportInc.com/airport/bos/airplane/ba99/route/bos-alt
BOS-ALT
http://www.airportInc.com/airport/bos/airplane/fx99
FX12
http://www.airportInc.com/...fx99/route/bos-lax
BOS-LAX
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
41
Content Types
Adaptability and Survival on the Web
• In nature, variety breeds adaptation which means survival.
• Many different types of clients use the Web and require
information in different "representations".
• Representations are expressed through content type
(MIME).
– HTML, GIF, JPEG, XML, MP3, MPEG, SVG, Text, CSS, SOAP
• A web service lives in an ecosystem, serving many different
types of clients, and therefore must work with information
in a representation matched to each.
• The more content types a web service offers, the more
clients can use the service; that variety breeds adaptation
which means survival.*
* Corollary: A web service that offers only one content type is destined for extinction.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
42
Resources and Representations
• A resource is a conceptual entity, but the
contents you work with are real.
• Issue a URL to a resource and you get back
a (real) representation of it.
• The power of the
Web comes from
URL
resource
navigating through
representation
conceptual resources
(w/ MIME type)
but working with real
representations.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
43
Example of Resource and
Representation
Browser
Client
http://www.aircraftsInc.com/boeing747
Boeing747
Aircraft
Fuel requirements
Maintenance schedule
...
Boeing747.html
The Client invokes a Web resource by issuing its identifier (URL).
A representation of the resource is returned (in this case as an HTML document).
What content type (MIME) type should a resource return?
Answer: the type selected is "dynamically based on the
capabilities or desires of the recipient and the nature of the
resource." (Roy Fielding)
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
44
Content (MIME) Types
Thriving in the Web Ecosystem Today
Common
Name
MIME Type
HTML
Text
XML
SOAP
GIF
CSS
SVG
JPEG
MPEG
…
text/html
text/plain
application/xml
application/soap+xml
image/gif
text/css
application/svg+xml
image/jpeg
video/mpeg
…
There are over 350 content types
Obsessing over a specific representation does not serve us well
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
45
Information Exchange
Trade Documents, not Arguments
• The Web is a new programming environment.
• The challenge of the Web is to think in terms of
information exchange with resources.
• On the Web you work with resources in the form
of documents with specific content types.
• The architectural principles underlying the
scalability of the Web dictate that documents
avoid information specific to the intended
processing, the destination service, or other details
of implementation.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
46
Can we Cross the Bridge?
Structured programming taught us to break a
problem into logical units of code (subroutines).
OOP introduced the manipulation of objects in
place of blocks of processing.
Resources,
information exchange,
content types, URLs
Programming
the Web
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
47
Coupling versus Loose Coupling
Client
CalcRoute
(BOS,
LAX,
ATL)
-- data --.
Subroutine CalcRoute
arguments:
starting-point,
ending-point
waypoint-list
...
• Contains process-specific info, e.g.,
- the name of the subroutine (CalcRoute)
• It couples the client to the web service.
• Tainted by prior experience with
OO and structured programming.
resource A
Client
-- data --.
resource B
Documents free of processing-specific information.
• client and service can evolve independently
• the document (data) can be used by other services
• the document (data) can be used in unanticipated ways
It enables the system to scale
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
48
Links
Connect, don't Encapsulate
• Links enable a scalable, loosely coupled network
of information.
• Links facilitate easy, quick assembly of
information.
• Changes to document content instantly propagate
to any document that references to it.
• The relations implied by links are themselves
information.
• Don't embed information. Link to information!
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
49
Link to Fuel and Maintenance
Browser
Client
http://www.aircraftsInc.com/boeing747
Boeing747
Aircraft
Fuel requirements
Maintenance schedule
...
Boeing747.html
The Web paradigm is networks of information.
Thus, the representation doesn't embed the fuel and
maintenance data, it links to it.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
50
Payload versus Protocol
The Right Information in the Right Place
• The payload is the body of the message and is
specific to the transaction.
• The protocol is the header of the message and is
general information for the transport.
• By design, information in the payload is hidden.
Application-specific information should be placed
in the payload.
• By design, information in the header is visible to
all. Information applicable to the Web community
at large should be placed in the header.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
51
This information
(the HTTP data) is
called the
HTTP header
Aircraft: F117
Callsign: Chrome
Tail Number: FX103
Pilot: Adam Vincent
Terminology:
Header and Payload
POST / HTTP/1.1
Host: http://tbmcs.centcom.af.mil
Aircraft: F117
Callsign: Chrome
Tail Number: FX103
Pilot: Adam Vincent
Component
(proxy filter, cache)
Flight Planner
Web Service
This information (the form data) is called the payload.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
52
Vantage Points
Information in every Direction
• The Web doesn't have a first page, last page, sections or
chapters. It's not a tree with leaves descending from a root.
• The Web allows you to jump into its huge collection of
information at any point.
• You land at a web site. You examine the links. You choose a
link. This defines your root, your viewpoint, your organizing
principle.
• Unlike taxonomies, which define single viewpoints, the Web
embraces many organizations of information.
• Designing information resources is not a matter of deciding on
the right hierarchy or organization, but ensuring that links
exists for all meaningful relationships between individual
elements of information.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Airport Ground Crew
has this Viewpoint
("a plane flies a route")
BA99
BOS-ALT
FX12
BOS-LAX
53
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
54
Pilot has this Viewpoint
("a route flown by a plane")
BOS-ALT
BA99
BOS-LAX
FX12
Links enable both viewpoints!
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
55
Link in Directions that may not
Fit your Mental Model
Plane: BA99
BOS-ALT.html
Suppose that you are a member of the airport's ground crew.
Your mental model is that "an airplane flies a route". Thus,
in the information for a route you may be tempted to just provide
information about the route. Resist the temptation! Insert a link
to the plane that flies the route. It will support other mental
models, e.g., the pilots.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
56
Summary
• Resources are the entities (resources) that you want your clients to
access and manipulate.
• URL’s uniquely identify each resource.
• Content types integrate resources with the whole web -- a resource
must be ready to respond to a client with a representation of an
appropriate content type.
• Information exchange: avoid processing-specific information in
web documents.
• Links create a network of information.
• Payload versus protocol puts network-specific information in the
HTTP header and application-specific information in the payload.
• Viewpoints enable resources to be traversed in whatever fashion
makes sense to clients.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
57
Case Study
Implementing Priorities
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Case Study:
Airline Reservation Service
• Suppose that an airline wants to create a
telephone reservation system for customers
to call in and make flight reservations.
• The airline wants to ensure that its premier
members get immediate service, its frequent
flyer members get expedited service and all
others get regular service.
• There are two main approaches to
implementing the reservation service ...
58
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
59
Approach 1
"Press 1 for Premier, Press 2 for…"
The airline provides a single telephone number.
Upon entry into the system a customer encounters an
automated message, "Press 1 if you are a premier member,
press 2 if you are a frequent flyer, press 3 for all others."
Premier
Customer
Representative
Premier Members
Airline Reservations
Answering
Machine
F.F.
Customer
Representative
Frequent Flyer Members
Regular Members
Regular
Customer
Representative
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
60
Approach 2
Telephone Numbers are Cheap! Use Them!
The airline provides several telephone numbers - one number
for premier members, a different number for frequent flyers,
and still another for regular customers.
1-800-Premier
Premier
Customer
Representative
Premier Members
1-800-Frequent
F.F.
Customer
Representative
Frequent Flyer Members
1-800-Reservation
Regular Members
Regular
Customer
Representative
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
61
Discussion
• In Approach 1 the answering machine
introduces an extra delay, which is
particularly annoying to premier members.
• With Approach 2 there is no intermediate
step. Premier members get instant pickup
from a customer service representative.
Others may have to wait for an operator.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
62
Web-Based Reservation Service
• Suppose now the airline (airlineInc.com) wants to
provide a Web reservation service for customers to
make flight reservations through the Web.
• Just as with the telephone service, the airline
wants to ensure that its premier members get
immediate service, its frequent flyer members get
expedited service, all others get regular service.
• There are two main approaches to implementing
the Web reservation service. The approaches are
analogous to the telephone service ...
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
63
Approach 1
One-Stop Shopping
The airline provides a single URL. A web service is
responsible for examining incoming client requests to
determine their priority and process them accordingly.
client
Premier
Customer
Premier Members
client
Frequent Flyer Members
Web
Reservation
Service
Determine
Priority
F.F.
Customer
Regular
Customer
client
Regular Members
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
64
POST / HTTP/1.1
Host: www.airlineInc.com
Destination: premier
This POST is accepted!
(but it shouldn't be)
PROXY FILTER
Problem with Hiding Multiple
Resources behind a Single URL
Proxy Filter Rules & Policies
Prohibit all POSTs to the premier service
Premier
Customer
Web
Reservation
Service
One URL
for all
services
F.F.
Customer
Regular
Customer
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
65
Approach 1 Disadvantages
• One URL hides multiple resources:
– Web components can't do their job since the actual destination is hidden in
the payload (Web components only examine the header).
– Search engines have access to only one URL. Thus, search metadata is for
only one URL.
• There is currently no industry accepted practice (rules) for expressing
priorities, so rules would need to be made. The clients must learn the
rule, and the web service application must be written to understand the
rule.
– Changing priorities may require the client to make changes in his software.
• This approach is based upon the incorrect assumption that a URL is
"expensive" and that their use must be rationed.
• The web service is a central point of failure. It is a bottleneck. Load
balancing is a challenge.
• It violates Tim Berners-Lee Web Design, Axiom 0.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Approach 2:
URLs are Cheap! Use Them!
The airline provides several URLs - one URL for premier
members, a different URL for frequent flyers, and still
another for regular customers.
http://www.airlineInc.com/reservations/premier
client
Premier Members
http://www.airlineInc.com/reservations/frequent-flyer
client
Frequent Flyer Members
http://www.airlineInc.com/reservations/regular
client
Regular Members
Premier
Member
Reservation
Service
Frequent
Flyer
Reservation
Service
Regular
Member
Reservation
Service
66
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
67
Approach 2 Advantages
• Web components (e.g., proxy filters) can properly function
since the target resources are visible in the HTTP header.
• The different URLs are discoverable by search engines.
• It's easy to understand what each service does simply by
examining the URL, i.e., it exploits the Principle of Least
Surprise.
• There is no need to introduce rules. Priorities are elevated
to the level of a URL. "What you see is what you get."
– The client can change priority simply by changing to a new URL.
• It's easy to implement high priority - simply assign a fast
machine at the premier member URL.
• There is no bottleneck. There is no central point of failure.
• Consistent with Axiom 0.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
68
Summary
• URLs are cheap, use them!
• Don't hide multiple resources behind a
single URL.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
69
Logical URLs,
Physical URLs,
Resources, and
Representations
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
70
Representation and Reality
• Foucault was playing
with the distinction
between a reality and its
representation.
• It is important to
understand the
difference between a
resource and its
representation when
modeling on the Web.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
71
Representation and Reality
• Another example to
demonstrate the
distinction between a
reality and its
representation.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
72
Physical URLs
• A physical URL contains a reference to
either:
– An implementation
• Example: http://www.airlineInc.com/servlet/747
– This URL indicates a specific implementation technology,
Java servlets.
– A specific content (MIME) type
• Example: http://www.camera.com/cannon.html
– This URL indicates a specific content type, HTML.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
73
Disadvantage of Physical URLs
• Example: http://www.airlineInc.com/servlet/747
– Java servlets have well-known security problems. Announcing in the
URL that servlets are being used at the server is an invitation to every
hacker to try to exploit the servlet vulnerabilities.
– Today airlineInc.com implements the resource that is being identified by
the URL using Java servlets. Suppose that tomorrow the implementation
is changed. Although the above URL could still be used, it would no
longer be appropriate.
• Example: http://www.camera.com/cannon.html
– This URL is referencing an HTML document. Implicitly the URL is
assuming the clients will always be browser-based (eyeball-based). Given
the fact that the variety of clients on the Web is becoming increasingly
diverse, the assumption is very limiting.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
74
Logical URLs
• A logical URL provides an identifier for a
resource. It does not use implementation
references, nor does it indicate a content
(MIME) type.
– Example: http://www.airlineInc.com/747
– Example: http://www.camera.com/cannon
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
75
Advantage of Logical URLs
747
robot
MP3 Player
(audio)
• Many different clients can access the
resource using the same URL.
• A logical URL is a loose coupler
between the client and the resource.
• Content type is determined by the resource.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
76
Content Type
• What you fetch is a resource.
• What you receive is a
representation in the form of
a particular content type.
The Scream
Scream.jpg
Scream.png
Scream.bmp
Edward Munch's The Scream (1893) National Gallery, Oslo
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
77
Web Services are Nothing Special
• There is no fundamental difference between
a browser interacting with a resource, and a
web service interacting with a resource.
The only difference is the format of the
response document - HTML is returned to
the browser, XML is returned to the web
service.
• It's all about the content, not the content
type!
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
78
FAQ
• "If a URL doesn't reference a particular content type (e.g., 747.html)
then how will the resource being referenced know what type of
document to return?"
• Recall HTTP. When you issue a GET, an HTTP header is created (e.g.,
the browser automatically constructs it for you when you submit a
URL). The HTTP header contains many header fields, one of them is
used to indicate what type of document the client desires from the
resource:
– "The Accept header, which is a request header, lets a client explicitly
indicate what types of content it can accept in the message body of the
server's response." (HTTP specification)
GET /747 HTTP/1.1
Host: www.airlineInc.com
Accept: text/html
747
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
79
"Why Does It Matter whether I
use Logical or Physical URLs?"
• The Web is comprised of many types of clients.
• A service that can have exchanges with only one
type of client is destined for extinction.
• Logical URLs are a way of announcing to the Web
ecosystem, "I have created a resource and I am not
limiting the type of client that can use my
resource."
• Thus, logical URLs pave the way to
unanticipated uses because a service can evolve
with its environment.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
80
Summary
• Physical URLs denote specific implementations.
• Logical URLs name resources.
• Logical URLs are decoupled from
implementations.
• Content types are specific implementations for
resources.
• Logical URLs open the door to unanticipated use.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
81
Links
and the
Structure of Knowledge
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
82
Connections
• Burke's work argued for the
connection of seemingly unrelated
events.
• He exposed the role of serendipity
and inevitability in invention.
• His novel interpretations led to the
insight that connections are as
important as what they connect.
• He realized that understanding
required understanding connections.
• Presenting information on the Web
requires more than feeding facts.
It's about connecting facts that
enable clients to weave a picture.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
83
What are their Connections?
• What is the connection between:
– Thomas Kuhn and cash registers?
– Dentistry and George Washington?
We visited Wikipedia and found their connections ...
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
84
Thomas Kuhn and cash registers
Thomas Kuhn
The Structure of Scientific Revolutions
Harvard University
Charles William Elliot
Panic of 1857
Embezzlement
cash registers
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
85
Dentistry and George Washington
Dentistry
United States
Thirteen Colonies
American Revolutionary War
George Washington
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
86
The Old Way of
Structuring Knowledge
• For millennia mankind has attempted to structure
knowledge into nice, neat categories.
• Mankind has attempted to build a single, definitive
set of categories into which everything fits.
• Some notable examples:
– Dewey Decimal System
– Periodic Table of the Chemical Elements
– Scientific Classification
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
87
Problem with the Old Way of
Structuring Knowledge
• People don't always think in linear, taxonomic
fashions
• People find things by searching around in the area
of interest
• New information violates the old structure
– New disciplines arise that don't fit into a slot in the
Dewey Decimal Systems
– Synthetic elements challenge the structure of the
Periodic Table
– Protista (single-celled organisms) don’t seem to be
exactly Animal, Vegetable, or Mineral
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
88
Messy Structure of Knowledge
• A taxonomy would put George Washington under
– President of the United States
– Rich men in colonial America
– Founding Fathers
• But in Wikipedia you might happen upon the entry
for George Washington while researching 18th
century dental practices!
• The world isn't organized into nice neat Dewey
Decimal slots.
• The structure of knowledge is messy.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
89
Connections as Knowledge
• Connections do more than relate what we know.
• Knowledge of the relations is itself information.
– Seeing how the facts are related to one another enables us
to understand things
• Understanding requires you to view information
within a context of connections to other information
• For example, Protestantism arose because:
– The Roman Catholic church needed money for the Basilica, so it started
selling indulgences (buy your way out of sin)
– Gutenberg's business depended on quickly creating indulgences
– Martin Luther became disgusted with the indulgences, and
consequently separated from the Church
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
90
Links: Key to Representing Information
• The hard part in representing information is in
identifying meaningful links.
• What is a meaningful link?
– Representing all the elements according to the number of electrons
in their electron shell is the organizing principle of the periodic
table. It is a meaningful organization, but not the meaningful
organization.
– The challenge is to think about the way links connect things.
• A meaningful link allows you to recast the
structure of knowledge.
• The Web is a technology that allows us to
represent knowledge as flexibly as the world does.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Structuring Knowledge
for the Web
Suppose that you own a store and in your store you have, among other things, digital
cameras. You may classify the digital cameras under photographic equipment. If this
were a web site you wouldn't put it in just one category. You would put it in as many
categories as possible. It's to your advantage to have it show up every place someone
might be looking for digital cameras.
In the real world you want a neat, clean, clear, and unambiguous classification scheme.
Dewey Decimal is very neat and simple – it’s a simple branching structure. Whereas in
the Web and other digital environments you want as much mess as possible, e.g., you
want the camera linked all over the place, the more links the more value. Messiness is a
virtue on the Web!
Excerpt from a talk titled Digital Future by David Wienberger
91
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
92
Each User has his own
Vantage Point
THE WEB
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
93
Many Vantage Points for
Messy Knowledge
• Many vantage points mean:
– I can organize information around any starting point.
• A starting point is any resource that's exposed on the Web. I
can start traversing links from that starting point.
• In order to satisfy unanticipated users, you have to be
able to organize information around any starting point.
That's what it is to satisfy different vantage points.
• I have a certain view of the world. I want information
organized by my world view. You have a different
view of the world. You want information organized
by your world view. The Web supports both!
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
94
No Single Vantage Point
• We are compelled to believe that knowledge has a
single, natural, and inherent structure.
• So we constantly want to put knowledge into a
structure.
• The fact is that knowledge is unstructured.
• It is because knowledge is unstructured that we
can cast it into many different structures.
• A vantage point captures the fact that we can
recast the structure of knowledge.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
95
Summary
• Connections are as important as facts.
• There is not just one way to organize information.
• The Web captures/mirrors/allows you to do the same thing as the
messiness of knowledge.
• Messiness is a virtue of the Web.
• The Web is a much better way of representing knowledge than the
Dewey Decimal system, or the Periodic table, or any a priori
classification system.
• A vantage point converts unorganized information into structured
knowledge.
• Links are what makes possible unanticipated use because the user can
organize the information from his vantage point.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
96
Guidance
Do's and Don'ts
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
97
Guidance, Do's and Don'ts
---Net-Centric XML
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
98
No man is an island ...
No man is an island, entire of itself; every man is a piece
of the continent, a part of the main. If a clod be washed
away by the sea, Europe is the less, as well as if a promontory
were, as well as if a manor of thy friend's of thine own were.
Any man's death diminishes me because I am involved in
mankind; and therefore never send to know for whom the
bell tolls; for it tolls for thee.
-- John Donne
The point is: there's no such thing as a disconnected thing. Everything must interest me!
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
99
Browsing Linked Information
http://www.airportInc.com/airports/
bos
The Web paradigm is about
linking information to other
information.
1
2
HTML
BOS
BOS-ALT
BOS-LAX
BA99
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
100
Why Links are Valuable
• More links make it easier to find things.
• The value of a network is proportional to
the square of the number of links.
Metcalf's Law
Value ~ N2
# Links
1
10
100
Value
1
100
10000
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
101
Linked Web Documents
• You are very accustomed to creating and using
HTML documents that contain links.
• Likewise, XML documents should contain links.
XML
XML
XML
XML
XML
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
102
Linking in XML
• XLink is the technology for linking XML documents.
• This technology defines many attributes, but the attribute
that is important for this discussion is "href" (hyperlink
reference).
• Use xlink:href to link an XML document to a resource.
<Airport icao="BOS"
xmlns:xlink="http://www.w3.org/1999/xlink/namespace">
Boston Airport DATA
<Airplane xlink:href="http://www.airportInc.com/airport/bos/airplane/ba99"/>
</Airport>
Use the XLink href attribute to link to other information.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
103
Example - Boston Airport Data
• Problem: organize information about the Boston airport. The Boston
airport (BOS) has these airplanes (tail number): FX12 and BA99.
FX12 flies this route: BOS-LAX. BA99 flies this route: BOS-ALT.
• You might be tempted to create a monolithic XML document that
contains all the information:
<Airport icao="BOS">
Boston Airport Data
<Plane tail-num="FX12">
Plane FX12 Data
<Route id="BOS-LAX">
Boston to LAX Route Data
</Route>
</Plane>
<Plane tail-num="BA99">
Plane BA99 Data
<Route id="BOS-ALT">
Boston to ALT Route Data
</Route>
</Plane>
</Airport>
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
104
Your Document is an Island!
• The Web is all about creating a network of
information, but you have designed a
document not linked to the rest of the Web.
• XML islands are of low value.
• Create high value XML documents by
linking to other resources!
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
105
Airport Data using
a Web Design
BOS.xml
BOS-LAX.xml
BOS-ALT.xml
FX12.xml
In the Web these resources can be discovered from the outside,
and these resources can lead to other "outside" resource. Everything is connected!
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
106
Applying the Paradigm
to Machines
http://
www.airportInc.com/airports/bos
2
• An XML representation
1
should link to other
information, just like an
HTML representation links to
other information.
XML
BOS
BOS-LAX
BOS-ALT
FX12
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
107
Link, don't Embed
<Airport icao="BOS"
xmlns:xlink="http://www.w3.org/1999/xlink/namespace">
Boston Airport DATA
<Airplane xlink:href="http://www.airportInc.com/airport/bos/airplane/ba99"/>
<Airplane xlink:href="http://www.airportInc.com/airport/bos/airplane/fx12"/>
<Route xlink:href="http://www.airportInc.com/airport/bos/airplane/ba99/route/bos-alt"/>
<Route xlink:href="http://www.airportInc.com/airport/bos/airplane/fx12/route/bos-lax"/>
<Weather xlink:href="http://www.weather-co.org/city/bos"/>
<Road-Conditions xlink:href="http://www.airport-co.org/airport/bos/roads"/>
</Airport>
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
108
Summary
• The more links you have to other
information, the more valuable is your
information.
• XLink is the technology for linking XML
documents to other resources.
• Insert links into your XML documents!
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
109
Guidance, Do's and Don'ts
---"Getting Information"
versus
"Doing Things"
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
110
Common Fallacy
Web services are different than ordinary web
usage. I agree that in the ordinary web you
exchange information (documents). But web
services are not about "getting information"
(documents), they’re about "doing things".
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
111
Activity as a Result of
Information Exchange
• Doing things is a consequence of
information exchange.
– Example: (At my bank) "Here's my deposit."
The response is "Here's your receipt." The
consequence is my bank account is updated.
• The actions that occurred by the bank during this
information exchange is totally opaque to me.
• Thus we can model "doing things" as
information exchange.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
112
The Web Paradigm is one of
Exchanging Information
Server
Information (document) goes into a web server.
A server responds with information (document).
How the server generated the response document is
opaque and irrelevant to the client. All the client needs
to know is that it sends the server some information,
and the server responds with some information.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
113
How does this Help me?
• Viewing web services as only one of "doing things" is
narrow vision.
• The cost for narrow vision is lost opportunity.
• The Web is an ecosystem, comprised of many different
clients. These clients operate by exchanging documents of
different content types.
• For your web service to operate with the rest of the Web,
you must adopt the Web paradigm of exchanging
information.
• The Web is a large network for the interchange of
information. It is a mechanism, a conduit, for information
exchange. That’s why we have this paradigm shift. It’s
not about invoking subroutines; it’s not process; it’s not
procedure oriented. It’s about exchanging information.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
114
Summary
• A fundamental paradigm of the Web is
information exchange.
• "Doing things" can be modeled as information
exchange.
• When we create web services we need to exploit
the Web model of information exchange.
• A web service is not an isolated thing, it is part of
a larger ecosystem.
• An interaction with a web service must be one of
exchanging information (documents).
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
115
Guidance, Do's and Don'ts
---Characterizing Good
Web Services
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
116
Understanding within the
Context of a Paradigm
• In the following slides we will take a problem that you are
used to and recast it under the new (Web) paradigm.
• It will demonstrate how to understand problems from the
perspective of the new paradigm
• To give you a feel for how dramatically perspective and
behavior changes with a new paradigm, consider how the
outbreak of disease was reacted to before and after the
germ theory of disease:
• Before: "You are possessed by demons. You must be exorcised"
• After: "The sewage strewn on the streets are natural breeding ground
for disease. Wash your hands, clean up the streets."
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
117
Case Study:
Currency Converter Web Service
• Create a web service that is able to convert
a value in one currency into its equivalent
value in another currency, using the
currency rates for a particular date.
• Example: On Jan. 14, 2006 one hundred US
dollars was equivalent at close of trading to
3,956.92 Thai Baht.
• Let's suppose that the hostname for your
service is: www.traderInc.com
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
118
Step 1: Identify the Resource(s)
• The resource is a "currency conversion
form".
http://www.traderInc.com/currency-conversion-form
Currency Conversion
Form
Note that the URL is a logical URL
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
119
The client GETs the form by issuing the URL
1
USAGE
Client
http://www.traderInc.com/currency-conversion-form
Form (in a
representation
suitable for the
client)
Currency Conversion
Form
2
The client fills in the form, and then POSTs it
to the same URL (thereby "updating" the form)
http://www.traderInc.com/currency-conversion-form
3
Completed
Form
Currency Conversion
Form
Client
Form with
the
results
4
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
120
Halt! Wrong Direction
• We are heading in the wrong direction.
• The name "Currency Converter" should have
immediately alerted us to a problem. It's a
process.
– The currency converter "form" is a facade for the intent
to do something. It is the old programming paradigm
insidiously sneaking onto the Web.
• The Web paradigm is not about invoking
processes, it's about exchanging information.
• A Currency Converter is not an appropriate
web service.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
121
Analogous to a Document
Converter Web Service
Would it be reasonable to create a web service that
converts document formats?
"Please convert from HTML to MP3"
US News.html
Document Format
Converter Service
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
122
News Service
"Please give me
the US news"
US News.html
2
1
"Please convert from HTML to MP3"
US News.html
3
Document Format
Converter Service
US News.mp3
4
Halt! Wrong Direction
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
123
The Right Approach
1
"MP3 file please"
News Service
US News.mp3
2
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
124
Analogous to an Image
Conversion Web Service
Would it be reasonable to create an image conversion
web service?
"Please convert my image from .bmp to .jpg"
Map of
Boston.bmp
Image Format
Converter
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
125
Map Service
"Please give me
a map of Boston"
Map of
Boston.bmp
2
1
"Please convert my image from .bmp to .jpg"
Map of
Boston.bmp
3
Image Format
Converter
Map of
Boston.jpg
4
Halt! Wrong Direction
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
126
The Right Approach
1
"JPG format please"
Map Service
Map of
Boston.jpg
2
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
127
FAQ
•
•
"But suppose that I just obtained a .bmp file of an important image and I want
to make it available to clients through my web service. There are no other
formats (.jpg, .gif) currently available of the image. Isn't this an example of
where it would be useful to have a web service that does image format
conversion?"
Answer: No! Clearly conversion needs to be done, but that doesn't mean that a
separate web service should be created to do image conversion. There are
many open-source packages available for doing image conversion. The web
service should (internally) use one of these packages.
Client
"Please give me the
image in .jpg format"
image
converter
(open source)
Web Service
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
128
Fundamental Fallacy
• Fallacy: everything that can be done, should
be done on the Web.
• The fact is that many things should not be
done on the Web. Things that fit the Web
paradigm can reasonably be done on the
Web. Things that don't fit should either
– be recast into the Web paradigm, or
– not be done on the Web (use an application
instead)
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
129
Analogous to a Sorting
Web Service
Would it be reasonable to create a sorter web service?
"Please sort based on last name"
staff list
(unsorted)
Sorter
Service
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
130
Staff
"Please give me
the list of staff"
staff list
(unsorted)
2
1
"Please sort based on last name"
staff list
(unsorted)
3
Sorter
Service
staff list
(sorted)
4
Halt! Wrong Direction
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
131
The Right Approach
1
"Sorted by last name please"
Staff
staff list
(sorted)
2
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
132
Currency Converter
Web Service?
Is it reasonable to create a currency converter
web service?
"Please convert to Thai Baht"
Bank
statement
(USD)
John Doe
in Thailand
Currency
Converter
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
133
ATM
"Please give me
my bank
statement"
Bank
statement
(USD)
2
1
"Please convert to Thai Baht"
Bank
statement
(USD)
John Doe
in Thailand
3
Bank
statement
(THB)
4
Halt! Wrong Direction
Currency
Converter
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
134
The Right Approach
1
"Bank statement please"
ATM
John Doe
in Thailand
Bank
statement
(THB)
2
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
135
From Process Paradigm
to Information Paradigm
• Notice how we have recast the problems,
from "doing something" to "exchanging
information" (in an appropriate format):
– Instead of a document format converter, the news service
serves up news in different formats.
– Instead of an image format converter, the map service serves
up maps in different formats.
– Instead of a sorter service, the staffing service serves up the
staff list in various sorted orders.
– Instead of a currency converter service, the bank account
service serves up the balance in the proper currency.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
136
Have it your way
• Would you order your hamburger, be stuck
with accepting it with all the condiments,
and then take it to another counter where
you ask them "Would you please take off
the pickles, remove the ketchup, and add
more mustard?"
• No! You would order it the way you want
to eat it.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
137
Meeting Customer Expectations
• [1920s] Henry Ford said, "You can buy it (a
Model T) in any color, as long as it's black."
• [1923] Alfred Sloan understood the problem (that
Ford was not responding to customer needs) and
allowed customers to order cars in color.
• [1927] Chevrolet nearly put Ford out of business.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
138
Meeting Customer Expectations is all
about Providing Multiple Content Types
.html, .mp3, ...
News
USD, THB, ...
ATM
Map
Staff
sorted by last name, sorted by employee number, ...
.bmp, .jpg, .gif, ...
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
139
"But there is no USD, THB
content type"
GET /accounts/John_Doe/balance HTTP/1.1
Host: www.chase.com
Accept: THB
ATM
John Doe's
money
Likewise, there is no "sorted by last name" content type:
GET /staff HTTP/1.1
Host: www.company.org
Accept: Sorted by last name
Staff
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
140
Solution is Analogous to the Airline
Reservation Priority Example
Approach 1: Put an indication of the desired currency in the payload:
GET /accounts/John_Doe/balance HTTP/1.1
Host: http://www.chase.com
ATM
Desired Currency: THB
John Doe's
money
Approach 2: Put the desired currency into the URL:
GET /accounts/John_Doe/balance/THB HTTP/1.1
Host: http://www.chase.com
ATM
Best Practice: put into the URL
John Doe's
money
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
141
[Zen] mu: unask the question
• [Student] "How do I create a currency conversion
service?"
• [Master] You must unask the question. Reframe the
problem and explore it in terms of information
exchange.
• Recasting the problem into an information problem
leads to a different solution.
• The key to reframing the currency problem is seeing
that the resource is value and that it is represented in
different currencies.
Value
Client
"The cost of … is … Baht"
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
142
The Right Currency in the
Right Place
• An exciting aspect of the Web is that clients can see values
expressed in their native "language" when in their native
"environment".
– This is true whether you're talking about getting images in the right
format, getting documents in the right format, getting news the
way you want to hear it, or value in the right currency.
• A web service should (internally) convert to the currency
appropriate for the client.
– When you are at home (US) and booking the Bankok Hilton on
your credit card it (the Hilton) should quote room rates in USD.
– When you are at home and reserving a car from Hertz at Charles
de Gaulle airport it should quote car rates in USD.
– When you're withdrawing cash to buy lunch while in Bankok your
bank should show your balance in Thai Baht.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
143
Web Service Implementation for
John Doe's Bank Account
1
http://www.chase.com/account/john-doe/balance/USD
John Doe at ATM
in USA
John Doe's
money
100.00 USD
2
John Doe GETs a statement of his value in USD.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
144
Currency Received is that
Appropriate for the Country
(currency conversion is invisible)
1
http://www.chase.com/account/john-doe/balance/THB
John Doe at ATM
in Thailand
John Doe's
money
3,956.92 THB
2
John Doe GETs a statement of his value in Thai Baht.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
145
What Resource is Required to
Convert?
"Give me the ratio that Dollars and Baht
changed hands at the last trade of the day."
John Doe's
money
http://www.traderInc.com/foreign-exchange-trading/USD-THB/COB
conversion rate of
the last trade of the
previous day
The client uses the conversion rate to calculate
how many Thai Baht correspond to 100 USD.
Foreign Currency
Trading
This resource is a
record from the
marketplace of all the
foreign currency
exchanges
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
146
Summary
• The Web paradigm requires moving from an
emphasis on processing to an emphasis on
information.
• Rather than a client accepting information in a
fixed format, and then finding a way to convert it
to the desired format, the service delivers it the
way the client wants.
• The conversion of information is not a separate
process, it's an integral part of responding to
client requests.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
147
Guidance, Do's and Don'ts
---Characterizing Good
Web Documents
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
148
Create XML that is
Independent of Implementation
• It's not the case that "any old XML will
suffice."
• The following slides discusses the
importance of creating XML that is
free of implementation-specific
information.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Example of Poor
Web Document Design
BankInc Server
<Create-Account>
<name>John Doe</name>
<amount>100.00</amount>
<currency>USD</currency>
</Create-Account>
client
This Web document
contains information that is
specific to the BankInc
implementation, i.e., subroutine
name, parameter name.
subroutine
Create-Account
(String name,
Decimal amount,
String currency)
{
-- code to create account -}
149
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
BankInc Server
<Create-Account>
<name>John Doe</name>
<amount>100.00</amount>
<currency>USD</currency>
</Create-Account>
subroutine
Create-Account
(String name,
Decimal amount,
String currency)
{
-- code to create account -}
TravelForum Server
client
The XML document is a point-to-point
solution. It has implementation-specific
information. It cannot be used by other
web services.
subroutine
AccountGenerator
(Decimal a,
String n
String c)
{
-- code to create account -}
150
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
151
Why is the Web Document Bad?
• It is tied to a specific implementation.
– Good Web documents can be used in lots of different
ways.
• There are actually two transactions confused as
one.
– Creating an account
– Making a (initial) deposit
• It replicates information rather than linking to it.
– John Doe's identity information should be linked to,
thus making it usable in multiple situations.
• It fails to exploit the primary benefits of the Web.
– Reuse, atomic operations, links
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
152
Good Web Document Design
<Financial_Identity>
<Identity_Credentials xlink:href="a link to John Doe's identity credentials"/>
<Credit_Record xlink:href="a link to John Doe's credit record"/>
</Financial_Identity>
1. This document can be used for lots of financial transactions (e.g., I
could send the same document to Merrill Lynch to open a brokerage
account, or to a mutual fund to open an IRA account).
2. Using links, rather than embedding information, allows changes to
replicate instantly (e.g., when I change my address, the bank, the
brokerage firm, the mutual fund all get updated instantly).
3. "Where's the money?" Answer: After the account is created then
you can make a deposit. They are two separate transactions.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
153
A Good Web Document is
Reusable
<Identity_Credentials>
<Name>John Doe</Name>
<Address>…</Address>
<SSN xlink:href="link to the SSN admin"/>
<Phone>…</Phone>
</Identity_Credentials>
Bank
<Financial_Identity>
<Identity_Credentials xlink:href=" "/>
<Credit_Record xlink:href=" "/>
</Financial_Identity>
Merrill Lynch
<Credit_Record>
...
</Credit_Record>
IRA
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
154
Characterizing Good
Web Documents
client
web
service
Free of implementation-specific information. Advantages:
- Decoupled: There is nothing in the document that ties the client to a particular
web service. The client and server are decoupled. This promotes Web scalability.
- Independent Evolution: The client and server can evolve independently, e.g., the
server can change its implementation without impacting the client.
- Scalable: Multiple web services can potentially process the same information.
- Unanticipated Uses: The information can be used in ways never anticipated.
- Increased Information Value: The greater the number of web services that can
use the information and the greater the number of different ways the information
is used results in increased value of the information.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
155
Summary
• Good Web documents have lots of uses.
Poor documents only one.
• The information exchanged is the same.
Only the format changes.
• When designing a web service focus on the
essential.
– Information accepted by the service
– Information returned by the service
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
156
Closing Remarks
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
157
What is a Web Service?
A Web Service is a software implementation
for a resource, identified by a URL, and
reached using internet protocols.
The software converts the resource to an
appropriate content type.
If there were no conversion required, then
everything could be static; no software, no web
service, would be required.
The raison d'ètre we have the software is to
convert information.
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
158
Summary
• Understand web services as information
providers within a network of information.
• Link to other information within the
network.
• Exchange information with more than one
type of client.
• Think in terms of manipulating information,
not in terms of dispensing services.