1 copyright © [2006]. roger l. costello, timothy d. kehoe. all rights reserved. the web paradigm...
TRANSCRIPT
1
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
The
Web Paradigm ShiftThe Heretical Guide to Designing Web Services
by
Roger L. Costello and Timothy D. Kehoe
Last Updated: May 20, 2006
2
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
CONTENTS
1.
2.
3.
4.
5.
6.
7.
7.1
7.2
7.3
7.4
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
Net-centric XML
"Getting Information" versus "Doing Things"
Characterizing Good Web Services
Characterizing Good Web DocumentsClosing Remarks
3
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
What is a Web Service?
A Web Service is a software implementation of a resource, identified by a URL, reached using internet protocols.
4
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Web Basics*
* For an excellent introduction to Web basics, check out this book:HTTP Essentials by Stephen Thomas from Wiley Computer Publishers.
5
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
The Web
information
information
information
information
The Web is a network of information that can be traversed in many ways.
6
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Paths toInformation
7
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
What’s in a Name?http://www.cnn.com/2006/01/11/implosion.ap/index.html
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."
The host that holds what we want.
The resource that we are after.
8
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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.
9
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Retrieving Information
The server responds with, not only the data (the Webpage), but also a result code (200 means everything is OK)
GET URL
data + status code
1
2
ClientServer
10
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
HTTP GET
CNN Server
GET /US_News HTTP/1.1Host: www.cnn.com
GET /US_News HTTP/1.1Host: www.cnn.com
http://www.cnn.com/US_News
- 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)
11
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Updating Information
The client provides information. The server respondswith a result code (200 means everything is OK)
POST URL + data
data + status code
1
2
ClientServer
12
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
HTTP POST
Chase Server
POST /customer/john_doe/address HTTP/1.1Host: www.chase.com
POST /customer/john_doe/address HTTP/1.1Host: www.chase.com
• 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)
Street Address: 91 Tremont St.City: BostonState: MAZipcode: 01710
Street Address: 91 Tremont St.City: BostonState: MAZipcode: 01710
91 Tremont St.
SUBMIT
Street:
BostonCity:
MAState:
01710Zip:
Change of Address Form
13
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Providing Information
POST is used to update existing information on the server.PUT is used to make new information available on the server.
PUT URL + data
data + status code
1
2
ClientServer
14
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Removing Information
The client requests that the server remove informationidentified by the URL. Typically a server will return an acknowledgement that it has deleted the requested data.
DELETE URL
data + status code
1
2
ClientServer
15
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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.
16
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Firewalls and Proxy Filters("Should I allow POSTing to SallysPornShop?")
POST /personals/SallysPornShop HTTP/1.1Host: www.geocities.com
POST /personals/SallysPornShop HTTP/1.1Host: www.geocities.com
Item: Sally in lingerieCredit Card: VisaNumber: 1234-5678-9012-6789Expiry: June 2006
Item: Sally in lingerieCredit Card: VisaNumber: 1234-5678-9012-6789Expiry: June 2009
Item: Sally in lingerieCredit Card: VisaNumber: 1234-5678-9012-6789Expiry: June 2009
PR
OX
Y F
ILT
ER
Proxy Filter Rules & PoliciesProhibit all POSTs to the SallysPornShop Web site.
Proxy Filter Rules & PoliciesProhibit all POSTs to the SallysPornShop Web site.
– The proxy filter decides whether an HTTP message should pass
– This message is rejected!
17
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
RoutersSource host
PC
To: Destination hostRouter 1
(Protocol address)(Physical address)
Packet
Router 1
To: Destination hostRouter 2
(Protocol address)(Physical address)
Packet
Router 2
Router 3
To: Destination hostRouter 3
(Protocol address)(Physical address)
Packet
To: Destination hostDestination host
(Protocol address)(Physical address)
PacketDestination hostPC http://www.cisco.com/univercd/cc/td/doc/cisintwk/ito_doc/routing.html
18
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Caches
First access, goesall the way backto the server withthe data (originserver)
Next access, thecache returnsthe data.
GET
1
ClientServerCache
GET
2
data + status code
3
data + status code
4
GET
5
ClientServerCache
data + status code
6
19
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
Web Message
Check this!
Component(proxy filter, cache)
Component(proxy filter, cache)
Firewalls and routers use lower-level information, such as IP addresses.
20
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Header and Payload
This information (the form data) is called the payload.
This information(the HTTP data)
is called the HTTP header
Chase Server
POST /customer/john_doe/address HTTP/1.1Host: www.chase.com
POST /customer/john_doe/address HTTP/1.1Host: www.chase.com
Street Address: 91 Tremont St.City: BostonState: MAZipcode: 01710
Street Address: 91 Tremont St.City: BostonState: MAZipcode: 01710
91 Tremont St.
SUBMIT
Street:
BostonCity:
MAState:
01710Zip:
Change of Address Form
21
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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.
22
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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
23
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
The Web Paradigm Shift
24
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
"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?
25
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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.
26
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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.
27
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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.
28
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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
29
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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"
Serverinformation
information
ClientWhat "actions" the server performsto generate the output informationare opaque to the client.
30
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
The Web Paradigm: a Network of Linked Information
Observe that the information can comein many different formats - text, audio,video, and others.
The latest newsin Iraq is not good.Five more US army. . .
31
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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.
32
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
7 Laws of Web Service Design
33
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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
34
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
ResourcesPrimal 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.
35
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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.
36
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
• 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.
Identifying Resources
37
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Boston Airport Resources
BOS
FX12
BOS-LAX
BA99
BOS-ALT
Note: a circle is used to depict a resource
38
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
URLsIdentify 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.
39
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Web Design, Axiom 0(Tim Berners-Lee, director of W3C)
• Axiom 0: all resources on the Web must be uniquely identified with a URI.
resource1URL1
resource2URL2
resource3URL3
40
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Identify the Airport Resources with URLs
http://www.airportInc.com/airport/bosBOS
FX12
BOS-LAX
BA99
BOS-ALT
http://www.airportInc.com/airport/bos/airplane/ba99
http://www.airportInc.com/airport/bos/airplane/fx99
http://www.airportInc.com/...fx99/route/bos-lax
http://www.airportInc.com/airport/bos/airplane/ba99/route/bos-alt
41
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Content TypesAdaptability 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.
42
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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.
resourceURL
representation(w/ MIME type)
• The power of the Web comes from navigating through conceptual resources but working with real representations.
43
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Example of Resource and Representation
Boeing747Aircraft
BrowserClient
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).
Fuel requirementsMaintenance schedule...
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)
http://www.aircraftsInc.com/boeing747
44
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Content (MIME) TypesThriving in the Web Ecosystem Today
HTMLTextXMLSOAPGIFCSSSVGJPEGMPEG…
text/htmltext/plainapplication/xmlapplication/soap+xmlimage/giftext/css application/svg+xml image/jpegvideo/mpeg…
MIME TypeCommonName
There are over 350 content typesObsessing over a specific representation does not serve us well
45
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Information ExchangeTrade 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.
46
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Can we Cross the Bridge?
Resources, information exchange, content types, URLs
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.
Programming the Web
47
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Coupling versus Loose Coupling
Subroutine CalcRoutearguments: starting-point, ending-point waypoint-list...
Client
CalcRoute(BOS, LAX, ATL)-- data --.
• 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.
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
resource A
resource B
Client -- data --.
48
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
LinksConnect, 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!
49
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Link to Fuel and Maintenance
The Web paradigm is networks of information.Thus, the representation doesn't embed the fuel and maintenance data, it links to it.
Boeing747Aircraft
BrowserClient
Boeing747.html
Fuel requirementsMaintenance schedule...
http://www.aircraftsInc.com/boeing747
50
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Payload versus ProtocolThe 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.
51
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Terminology: Header and Payload
Flight PlannerWeb Service
POST / HTTP/1.1Host: http://tbmcs.centcom.af.mil
POST / HTTP/1.1Host: http://tbmcs.centcom.af.mil
Aircraft: F117Callsign: ChromeTail Number: FX103Pilot: Adam Vincent
Aircraft: F117Callsign: ChromeTail Number: FX103Pilot: Adam Vincent
Aircraft: F117Callsign: ChromeTail Number: FX103Pilot: Adam Vincent
This information (the form data) is called the payload.
This information(the HTTP data) is
called the HTTP header Check this!
Component(proxy filter, cache)
Component(proxy filter, cache)
52
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Vantage PointsInformation 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.
53
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Airport Ground Crew has this Viewpoint("a plane flies a route")
FX12
BOS-LAX
BA99
BOS-ALT
54
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Pilot has this Viewpoint("a route flown by a plane")
BOS-LAX
FX12
BOS-ALT
BA99
Links enable both viewpoints!
55
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Link in Directions that may not Fit your Mental Model
Plane: BA99
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 provideinformation 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.
BOS-ALT.html
56
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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.
57
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Case StudyImplementing Priorities
58
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 ...
59
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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 Members
Frequent Flyer Members
Regular Members
Airline ReservationsAnsweringMachine
PremierCustomer
Representative
F.F.Customer
Representative
RegularCustomer
Representative
60
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Approach 2Telephone 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.
Premier Members
Frequent Flyer Members
Regular Members
1-800-PremierPremier
CustomerRepresentative
F.F.Customer
Representative
RegularCustomer
Representative1-800-Reservation
1-800-Frequent
61
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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.
62
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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 ...
63
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Approach 1One-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.
Premier Members
Frequent Flyer Members
Regular Members
Web Reservation
Service
DeterminePriority
PremierCustomer
F.F.Customer
RegularCustomer
client
client
client
64
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Problem with Hiding Multiple Resources behind a Single URL
POST / HTTP/1.1Host: www.airlineInc.com
POST / HTTP/1.1Host: www.airlineInc.com
Destination: premierDestination: premier
PR
OX
Y F
ILT
ER
Proxy Filter Rules & PoliciesProhibit all POSTs to the premier service
Proxy Filter Rules & PoliciesProhibit all POSTs to the premier service
This POST is accepted!(but it shouldn't be)
Web Reservation
Service
PremierCustomer
F.F.Customer
RegularCustomer
One URLfor all
services
65
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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.
66
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.
Premier Members
Frequent Flyer Members
Regular Members
client
client
client
http://www.airlineInc.com/reservations/premier
http://www.airlineInc.com/reservations/frequent-flyer
http://www.airlineInc.com/reservations/regular
PremierMember
ReservationService
FrequentFlyer
ReservationService
RegularMember
ReservationService
67
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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.
68
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Summary
• URLs are cheap, use them!
• Don't hide multiple resources behind a single URL.
69
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Logical URLs, Physical URLs,Resources, andRepresentations
70
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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.
71
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Representation and Reality• Another example to
demonstrate the distinction between a reality and its representation.
72
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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.
73
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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.
74
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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
75
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Advantage of Logical URLs
747robot
MP3 Player(audio)
http://www.airplace-co.com/747
http://www.airlineInc.com/747
http://www.airlineInc.com/747
• 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.
76
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Content Type• What you fetch is a
resource.
• What you receive is a representation in the form of a particular content type.
Scream.jpg
Scream.png
Scream.bmp
The Scream
Edward Munch's The Scream (1893) National Gallery, Oslo
77
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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!
78
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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)
747
GET /747 HTTP/1.1Host: www.airlineInc.comAccept: text/html
GET /747 HTTP/1.1Host: www.airlineInc.comAccept: text/html
79
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
"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.
80
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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.
81
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Links and the
Structure of Knowledge
82
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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.
83
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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 ...
84
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Thomas Kuhn and cash registersThomas Kuhn
The Structure of Scientific Revolutions
Harvard University
Charles William Elliot
Panic of 1857
Embezzlement
cash registers
85
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Dentistry and George Washington
Dentistry United States
Thirteen Colonies American Revolutionary War
George Washington
86
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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
87
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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
88
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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.
89
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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
90
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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.
91
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
92
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Each User has his own Vantage Point
THE WEB
93
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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!
94
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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.
95
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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.
96
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
GuidanceDo's and Don'ts
97
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Guidance, Do's and Don'ts----
Net-Centric XML
98
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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!
99
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
BOS-ALT
BOS-LAX
BA99
http://www.airportInc.com/airports/bos
HTMLBOS
Browsing Linked Information
1
2
The Web paradigm is about linking information to other information.
100
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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
# Links1
10100
Value1
10010000
101
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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
102
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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.
103
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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>
104
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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!
105
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Airport Data using a Web Design
BOS.xml
BOS-LAX.xml
FX12.xml
BOS-ALT.xml
In the Web these resources can be discovered from the outside, and these resources can lead to other "outside" resource. Everything is connected!
106
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
BOS-LAX
BOS-ALT
FX12
BOS
http:// www.airportInc.com/airports/bos
XML
Applying the Paradigm to Machines
1
2• An XML representation should link to other information, just like an HTML representation links to other information.
107
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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>
108
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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!
109
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Guidance, Do's and Don'ts----
"Getting Information"versus
"Doing Things"
110
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Common Fallacy
Web services are different than ordinary web usage. I agree that in the ordinary web youexchange information (documents). But webservices are not about "getting information"(documents), they’re about "doing things".
111
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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.
112
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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 isopaque and irrelevant to the client. All the client needsto know is that it sends the server some information,and the server responds with some information.
113
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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.
114
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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).
115
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Guidance, Do's and Don'ts----
Characterizing Good Web Services
116
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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."
117
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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
118
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Step 1: Identify the Resource(s)
• The resource is a "currency conversion form".
Currency ConversionForm
http://www.traderInc.com/currency-conversion-form
Note that the URL is a logical URL
119
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Currency ConversionForm
http://www.traderInc.com/currency-conversion-formClient
Form (in a representationsuitable for the
client)
The client GETs the form by issuing the URLU
SA
GE
1
2
Currency ConversionForm
http://www.traderInc.com/currency-conversion-form
Client
Form withthe
results
The client fills in the form, and then POSTs it to the same URL (thereby "updating" the form)
CompletedForm
3
4
120
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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.
121
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Analogous to a Document Converter Web Service
"Please convert from HTML to MP3"
US News.htmlDocument FormatConverter Service
Would it be reasonable to create a web service thatconverts document formats?
122
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
News Service
"Please give methe US news"
US News.html
1
2
Halt! Wrong Direction
Document FormatConverter Service
US News.mp3
3
4
"Please convert from HTML to MP3"
US News.html
123
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
The Right Approach
"MP3 file please"
1
2
News Service
US News.mp3
124
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Analogous to an Image Conversion Web Service
"Please convert my image from .bmp to .jpg"
Map ofBoston.bmp
Image FormatConverter
Would it be reasonable to create an image conversionweb service?
125
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
"Please convert my image from .bmp to .jpg"
Map ofBoston.bmp
Image FormatConverter
Map Service
"Please give mea map of Boston"
Map ofBoston.bmp
Map ofBoston.jpg
1
2
3
4
Halt! Wrong Direction
126
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
The Right Approach
"JPG format please"
Map ofBoston.jpg
1
2
Map Service
127
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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.
imageconverter
(open source)Client
"Please give me the image in .jpg format"
Web Service
128
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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)
129
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Analogous to a SortingWeb Service
"Please sort based on last name"
staff list(unsorted)
SorterService
Would it be reasonable to create a sorter web service?
130
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Staff
"Please give methe list of staff"
staff list(unsorted)
1
2
Halt! Wrong Direction
"Please sort based on last name"
staff list(unsorted)
SorterService
staff list(sorted)
3
4
131
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
The Right Approach
"Sorted by last name please"
1
2
Staff
staff list(sorted)
132
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Currency ConverterWeb Service?
Bankstatement
(USD)CurrencyConverter
Is it reasonable to create a currency converter web service?
"Please convert to Thai Baht"
John Doein Thailand
133
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
"Please give memy bank statement"
Bankstatement
(USD)
1
2
Halt! Wrong Direction
"Please convert to Thai Baht"
Bankstatement
(USD)CurrencyConverter
Bankstatement
(THB)
3
4
John Doein Thailand
ATM
134
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
The Right Approach
"Bank statement please"
1
2
ATM
Bankstatement
(THB)
John Doein Thailand
135
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
From Process Paradigmto 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.
136
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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.
137
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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.
138
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Meeting Customer Expectations is all about Providing Multiple Content Types
News
Map
Staff
ATM.bmp, .jpg, .gif, ...
.html, .mp3, ...
sorted by last name, sorted by employee number, ...
USD, THB, ...
139
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
"But there is no USD, THB content type"
John Doe'smoney
GET /accounts/John_Doe/balance HTTP/1.1Host: www.chase.comAccept: THB
GET /accounts/John_Doe/balance HTTP/1.1Host: www.chase.comAccept: THB
Likewise, there is no "sorted by last name" content type:
Staff
GET /staff HTTP/1.1Host: www.company.orgAccept: Sorted by last name
GET /staff HTTP/1.1Host: www.company.orgAccept: Sorted by last name
ATM
140
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Solution is Analogous to the Airline Reservation Priority Example
John Doe'smoney
GET /accounts/John_Doe/balance HTTP/1.1Host: http://www.chase.com
GET /accounts/John_Doe/balance HTTP/1.1Host: http://www.chase.com
Desired Currency: THBDesired Currency: THB
Approach 1: Put an indication of the desired currency in the payload:
John Doe'smoney
GET /accounts/John_Doe/balance/THB HTTP/1.1Host: http://www.chase.com
GET /accounts/John_Doe/balance/THB HTTP/1.1Host: http://www.chase.com
Approach 2: Put the desired currency into the URL:
ATM
ATM
Best Practice: put into the URL
141
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
[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.
ValueClient
"The cost of … is … Baht"
142
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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.
143
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Web Service Implementation for John Doe's Bank Account
John Doe'smoney
John Doe at ATM in USA
http://www.chase.com/account/john-doe/balance/USD
100.00 USD
1
2
John Doe GETs a statement of his value in USD.
144
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Currency Received is that Appropriate for the Country
(currency conversion is invisible)
John Doe'smoney
John Doe at ATMin Thailand
http://www.chase.com/account/john-doe/balance/THB
3,956.92 THB
1
2
John Doe GETs a statement of his value in Thai Baht.
145
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
What Resource is Required to Convert?
Foreign CurrencyTrading
http://www.traderInc.com/foreign-exchange-trading/USD-THB/COB
conversion rate ofthe last trade of the
previous day
The client uses the conversion rate to calculate how many Thai Baht correspond to 100 USD.
"Give me the ratio that Dollars and Baht changed hands at the last trade of the day."
This resource is a record from the marketplace of all the foreign currency exchanges
John Doe'smoney
146
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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.
147
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Guidance, Do's and Don'ts----
Characterizing Good Web Documents
148
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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.
149
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
client
BankInc Server
<Create-Account> <name>John Doe</name> <amount>100.00</amount> <currency>USD</currency></Create-Account>
<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 --}
This Web documentcontains information that isspecific to the BankInc implementation, i.e., subroutinename, parameter name.
Example of Poor Web Document Design
150
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
client
BankInc Server
TravelForum Server
subroutine AccountGenerator (Decimal a, String n String c){ -- code to create account --}
The XML document is a point-to-pointsolution. It has implementation-specificinformation. It cannot be used by otherweb services.
<Create-Account> <name>John Doe</name> <amount>100.00</amount> <currency>USD</currency></Create-Account>
<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 --}
151
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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
152
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Good Web Document Design
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.
<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>
153
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
A Good Web Document is Reusable
<Financial_Identity> <Identity_Credentials xlink:href=" "/> <Credit_Record xlink:href=" "/></Financial_Identity>
<Identity_Credentials> <Name>John Doe</Name> <Address>…</Address> <SSN xlink:href="link to the SSN admin"/> <Phone>…</Phone></Identity_Credentials>
<Credit_Record> ...</Credit_Record>
Bank
Merrill Lynch
IRA
154
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Characterizing Good Web Documents
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.
client webservice
155
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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
156
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
Closing Remarks
157
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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.
158
Copyright © [2006]. Roger L. Costello, Timothy D. Kehoe. All Rights Reserved.
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.