Upload
others
View
2
Download
0
Embed Size (px)
Citation preview
Web-services
Brian [email protected]
Why Web Services?
Today’s Web• Web designed for application to human interactions• Served very well its purpose:
– Information sharing: a distributed content library. – Enabled B2C e-commerce– Non-automated B2B interactions
• How did it happen?– Built on very few standards: http + html– Shallow interaction model: very few assumptions made about
computing platforms– Result was ubiquity (Existence everywhere at the same time)
What’s next?• The Web is everywhere. There is a lot more we can do!
– E-marketplaces.– Open, automated B2B e-commerce.– Business process integration on the Web.– Resource sharing, distributed computing. – Pervasive Embedded Computing
• Current approach is ad-hoc on top of existing standards.– e.g., application-to-application interactions with HTML forms.
• Goal: enabling systematic application-to-application interaction on the Web.
Web services
XML Application 2Application 1
Service Interface:Public operations / methods / procedures
Not necessarily strict request-reply interaction
Ex. http
What are Web Services• “Web services” is an effort to build a distributed
computing platform for the Web.• Yet another one!• Support a service oriented architecture (SOA).• Web service applications are encapsulated,
loosely coupled Web “components” that can bind dynamically to each other
• Programmatic interface to web-applications
What are Web Services?
• Identified by a URI• Interfaces defined using XML• Can be discovered by other systems• Interact using XML based messages
conveyed by Internet protocols
• “A Web service is a software system designed to support interoperable machine-to-machine interaction over a network.”
A Brief History …
1980 1985 1990 1995 2000 2005
SUN RPC
CORBA
DCE/RPC + COM
DCOM+ JavaRMI
Web Services
Main Differences:• Platform neutral• Open Standards
– Interoperable• Based on ubiquitous
software– XML Parsers– HTTP Server
• Internet-wide
Combination of web services
hotel bookinga
Travel Agent
flight booking
a
hire car bookingaService
Client
flight bookingb
hotel bookingb
hire car bookingb
Travel agent scenario1. The client asks the travel agent service for information about a set of services; for
example, flights, car hire and hotel bookings.2. The travel agent service collects prices and availability information and sends it to
the client, which chooses one of the following on behalf of the user:(a) refine the query, possibly involving more providers to get more information, then repeat step 2;(b) make reservations;(c) quit.
3. The client requests a reservation and the travel agent service checks availability. 4. Either all are available;
or for services that are not available; either alternatives are offered to the client who goes back to step 3; or the client goes back to step 1.
5. Take deposit.6. Give the client a reservation number as a confirmation.7. During the period until the final payment, the client may modify or cancel
reservations
Web Services Main Componentsweb-based SOA as new system design paradigm
Web services infrastructure and components
Security
Service descriptions (in WSDL)
Applications
Directory service
Web Services
XML
Choreography
SOAP
URIs (URLs or URNs) HTTP, SMTP or other transport
Recap XML
URI / URL / URN
• URI (Uniform Resource Identifier): a general ressource identifier, whose value may be eitherURL or URN– URL: includes resource location information
• http://www.cdk4.net/person– URN: (Uniform Resource Names): location
independent, rely on lookup service to map them ontothe URLs of resources
• urn:isbn:0-321-26354-5
URI
URL URN
XML• XML is a markup language defined by the World
Wide Web Consortium (W3C)• Both XML and HTML were derived from SGML
(Standardized Generalized Markup Language)– HTML: tags specify how a browser displays the text– XML: tags describe the logical structure of the
data• XML is extensible: users can define their own
tags (HTML uses a fixed set of tags)• XML in web service:
– Data types– SOAP messages in a published XML format– WSDL documents
XML definition of a person
• Element: <name>Smith</name>• Attribute: id="123456789“• items represented as elements or attributes:
– An element is generally a container for data– An attribute is used for labeling that data
<person id="123456789"><name>Smith</name><place>London</place><year>1934</year><!-- a comment -->
</person >
Namespaces• XML name spaces: provide scoping of names to avoid
name-clashes• URIs used to identify namespaces (specified in xmlns
attribute) • URI is a cheap way of getting unique names
– Developer controls hierarchy under the given URI. – (Doesn’t necessarily point to anything)
• In the example, prefix pers is bound to http://www.cdk4.net/person
<person pers:id="123456789" xmlns:pers = "http://www.cdk4.net/person“ ><pers:name> Smith </pers:name><pers:place> London </pers:place ><pers:year> 1934 </pers:year>
</person>
An XML schema Persons• An XML schema is an XML document that defines the
– elements and attributes that can appear in a document,– how the element are nested and the number of elements,– whether an element is empty or can include text.
• For each element, it defines the type and default value• Schema Languages: DTD, XML-Schema• An XML document may be validated against a schema• May be transformed (XSLT) Navigated / queried /Language bindings
<xsd:schema xmlns:xsd = URL of XML schema definitions ><xsd:element name= "person" type ="personType" />
<xsd:complexType name="personType"><xsd:sequence>
<xsd:element name = "name" type="xs:string"/> <xsd:element name = "place" type="xs:string"/> <xsd:element name = "year" type="xs:positiveInteger"/>
</xsd:sequence><xsd:attribute name= "id" type = "xs:positiveInteger"/>
</xsd:complexType></xsd:schema>
SOAP
Simple Object Access Protocolb
HTTP POST -SOAP Request
HTTP RESPONSE -SOAP Response
Protocol Binding: eg. SOAP over HTTP
Language BindingStub Compiler
Messaging using XML
SOAP• Used to mean Simple Object Access Protocol• From SOAP 1.2 > SOAP is no longer an acronym
• XML-based– uses XML to represent the contents of request and reply messages– Platform independent, language independent
• Transport: – HTTP– SMTP, FTP, TCP or UDP, (Jabber)
• Language Binding:– SOAP APIs available for many programming languages, – Java, Javascript, Perl, Python, .NET, C, C++, C#, and VB– Programmers do not normally need to concern how SOAP uses XML to
represent messages and HTTP to communicate them
SOAP message Envelopingenvelope
header
body
header element
body element
header element
body element
SOAP MessageEnvelope • specifies global settings, eg
encoding.
Header • Optional• Ultimate destination • encryption• routing & delivery settings• authentication/authorisation
information• transaction context• Other data extensions
Body• required• data or message to be processed• containing as many child nodes as
required
<SOAP-ENV:Envelope
xmlns="http://schemas.xmlsoap.org/soap/envelope/">
< SOAP-ENV:Header>...
</ SOAP-ENV:Header>
< SOAP-ENV:Body>...
</ SOAP-ENV:Body>...
</ SOAP-ENV: Envelope>
Request
• (s1,s2)=Exchange(“Hello”, “World”)
m:exchange
env:envelope xmlns:env =namespace URI for SOAP envelopes
m:arg1
env:body
xmlns:m = namespace URI of the service description
Hellom:arg2
World
Reply
• (s1,s2)=Exchange(“Hello”, “World”)• (”World”, ”Hello”)env:envelope xmlns:env = namespace URI for SOAP envelope
m:res1
env:body
xmlns:m = namespace URI for the service description
m:res2World
m:exchangeResponse
Hello
Use of HTTP POSTendpoint address
action
POST /examples/stringerHost: www.cdk4.netContent-Type: application/soap+xmlAction: http://www.cdk4.net/examples/stringer#exchange
<env:envelope xmlns:env= namespace URI for SOAP envelope ><env:header> </env:header><env:body> </env:body></env:Envelope>
Soa
p m
essa
geH
TTP
he
ader
Java WS interface ShapeListimport java.rmi.*;public interface ShapeList extends Remote {
int newShape(GraphicalObject g) throws RemoteException;
int numberOfShapes()throws RemoteException;int getVersion() throws RemoteException;int getGOVersion(int i)throws RemoteException;GraphicalObject getAllState(int i) throws
RemoteException;}
Java implementation of the ShapeList server
import java.util.Vector;public class ShapeListImpl implements ShapeList {
private Vector theList = new Vector();private int version = 0;private Vector theVersions = new Vector();public int newShape(GraphicalObject g) throws RemoteException{
version++;theList.addElement(g); theVersions.addElement(new Integer(version)); return theList.size();
}public int numberOfShapes(){}public int getVersion() {} public int getGOVersion(int i){ }public GraphicalObject getAllState(int i) {}
}
Java implementation of the ShapeList client
package staticstub;import javax.xml.rpc.Stub;public class ShapeListClient {
public static void main(String[] args) { /* pass URL of service */try {
Stub proxy = createProxy();proxy._setProperty
(javax.xml.rpc.Stub.ENDPOINT_ADDRESS_PROPERTY, args[0]); ShapeList aShapeList = (ShapeList)proxy;GraphicalObject g = aShapeList.getAllState(0);
} catch (Exception ex) { ex.printStackTrace(); }} private static Stub createProxy() {
return (Stub) (new MyShapeListService_Impl().getShapeListPort());
}}
SOAP Nodes
InitialSender
UltimateReceiver
Intermediary Intermediary
InitialSender
Intermediary Intermediary
InitialSender
UltimateReceiver
Intermediary Intermediary
Soap message may be destined to a set of intermediarynodes as well as an ultimate receiver
Intermediary Algorithm
• Receive message• Process appropriate header blocks
– Processing possibly produces a fault• Remove processed headers• Add new headers• Send message
WSDL
Web Services Description Language• WSDL (“Whistle”) W3 standard• XML-based language describing:
– What functionality is provided? – How should it be accessed?– Where is the service located?1. Allows industries to define standardized service
interfaces.2. Provides a normalized description of heterogeneous
applications.3. Allows advertisement of service descriptions,
enables dynamic discovery and binding of compatible services.
Used in conjunction with UDDI registry4. Generate compatible client and server stubs.
wsdl2javajava2wsdl
WSDL description
• Types: XML schema describing the used data types • Message: The structure of the messages exchanged• Interface: Information describing all publicly available functions• Bindings: Information about the transport protocol to be used• Services: Address information for locating the specified service
abstract concrete
how where
definitions
types
target namespace
interface bindings servicesmessage
document style request-reply style
1. One-way2. Request-
response3. Solicit-
response4. Notification
Operation patterns
Patterns for WSDL operations
Name
In-Out
In-Only
Robust In-Only
Out-In
Out-Only
Robust Out-Only
Client Server Delivery Fault messageRequest Reply may replace ReplyRequest no fault messageRequest guaranteed may be sentReply Request may replace Reply
Request no fault message
Request guaranteed may send fault
Messages sent by
Recipe Service• From “An Introduction to XML and Web Technologies” by Anders Møller &
Michael I. Schwartzbach• http://www.brics.dk/ixwt/examples/recipeserver.wsdl• http://www.brics.dk/ixwt/examples/recipes.xsd• http://www.brics.dk/ixwt/examples/recipes.xml• http://www.brics.dk/ixwt/examples/recipes.xsl
• Operations on recipe collection– getRecipe: returns the collection of recipes stored at the server– lockRecipe: optain lock at given recipe ID (or fals)– writeRecipe. Upload recipe to server– unlockRecipe: Releases the given lock
WSDL request and reply messages
messagename = "ShapeList_newShape"
type = " ns:GraphicalObject"part name ="GraphicalObject_1"
tns target namespace xsd XML schema definitions
messagename = " ShapeList_newShapeResponse "
part name=" result"type = " xsd:int"
WSDL operation newShape
operation name = "newShape"
input message = "tns:ShapeList_newShape"
output message = "tns:ShapeList_newShapeResponse"
pattern = In-Out
tns – target namespace xsd – XML schema definitions
The names operation, pattern, input and output are defined in the XML schema for WSDL
SOAP binding and service definitions
soap:binding transport = URI
binding
style= " rpc"
endpoint
servicename =
binding = " tns:ShapeListBinding"
soap:address
location = service URI
name = " MyShapeListService"
name = " ShapeListPort"for schemas for soap/http
the service URI is:
operation
soap:operationsoapAction
" ShapeListBinding"
" tns:ShapeList"type =
name=" newShape"
input
soap:bodyencoding, namespace
soap:bodyencoding, namespace
output
“http://localhost:8080/ShapeList-jaxrpc/ShapeList”
UDDI
UDDI• How does a client locate a service?
– Advertise through web-page– Use lookup service (UDDI)
• Universal Description, Discovery and Integration• UDDI defines the operation of a service registry• A UDDI Server acts as a registry for Web Services and
makes them searchable:– White pages (general information)– Yellow pages (categories of services)– Green pages (business rules)
• Accessible as SOAP web service and html• http://uddi.microsoft.com/• https://uddi.ibm.com/ubr/registry.html
Main UDDI data structures
tModel
businessServices
tModel
businessEntity
information
about the publisher
tModel
businessServiceshuman readable
service descriptions key key
URL
URL
URL
businessServices
information about a family of services
human readable
service interfaces
bindingTemplate
bindingTemplate
bindingTemplateinformation about the
keyservice interfaces
•businessEntity: name, address etc of the organization•businessServices: category information•bindingTemplate: holds address of a web service instance and references to service descriptions•tModel: holds service descriptions, usually WSDL documents, storedoutside the database and accessed by means of URLs
Outlook
WS-Extensions
• WS-security, WS-choreography• WS-flow,, WS-reliability, WS-transactions,
WS-membership, WS-CDL, WS-BPEL, WS-events, WS-Policy, WS-Routing, DIME, WS-Attachments, WS-management,…
• http://www.dotnet-collective.com/ws_extensions.html
(In)Efficiency
Sender Receiver
HTTP Request
HTTP Body
XML Syntax
SOAP Envelope
SOAP Body
SOAP Body Block
Textual Integer
0x0b66
–SOAP requests may be 14 times longer than CORBA–SOAP request may take 882 times as long as CORBA
Embedded Internet• Scenario
– A digital copier has detected a failure condition in one of its motors.
– Constructs a SOAP-encoded message and invoke a remote event web service.
– Causes invocation of other web services, such as submission of a service request into a field service application, as well as acheck on the availability of a spare motor from an inventory management system.
• Intelligent Home, E-Home• Facility Management• Sensor/actuator networks• Virtual world overlaying the real physical world
Embedded Web-servers
• Web-services Mobile Devices– gSOAP– Web Services Tool Kit for Mobile Devices (WSTKMD)
Plateau ofproductivity
Slope ofenlightenment
Trough ofdisillusionment
Peak ofinflated
expectationsTechnology
trigger
Gartner’s ‘Hype’ CurveKey: Time to “plateau”
Less than two yearsTwo to five yearsFive to 10 yearsBeyond 10 years
Biometrics Grid Computing
Web Services
Nanocomputing
Personalfuel cells
Text-to-speech
WirelessLANs/802.11
Virtualprivatenetworks
Visibility
Maturity
Source: Gartner Group June 2002
Natural-languagesearch
Identity services
Personal digitalassistant phones
E-tags
Speech recognition incall centers
Voice over IPBluetooth
Public key infrastructure
Speech recognition on desktopsLocationsensing
WAP/WirelessWeb
Peer-to-peercomputing
END