Grid Computing, B. Wilkinson, 2004 3a.1
WEB SERVICES
Introduction
Grid Computing, B. Wilkinson, 2004 3a.2
Web Services
• Software components designed to provide specific operations (“services”) accessible using standard Internet technology.
• For machine interaction over a network.
• Usually through SOAP (simple Object Access Protocol) messages carrying XML documents, and a HTTP transport protocol.
Grid Computing, B. Wilkinson, 2004 3a.3
Basic client-server model
Grid Computing, B. Wilkinson, 2004 3a.4
• Client needs to:– Identify location of the required service– Know how to communicate with the service
to get it to provide the actions required.
• Uses service registry - a third party.
Grid Computing, B. Wilkinson, 2004 3a.5
Service-Oriented ArchitectureSteps:
• Services “published” in a Service registry.
• Service requestor asks Service Registry to locate service.
• Service requestor “binds” with service provider to invoke service.
Grid Computing, B. Wilkinson, 2004 3a.6
2. Find
3. Bind
1. Publish
Service-Oriented Architecture
Service requester
Service registry
Service provider
Grid Computing, B. Wilkinson, 2004 3a.7
Key aspects
Has similarities with RMI and other distributed object technologies (CORBA etc.) but::
• Web Services are platform independent– They use XML within a SOAP message).– Most use HTTP to transmit message.
Grid Computing, B. Wilkinson, 2004 3a.8
XML-based Web Services
• XML provides a flexible basis for storing and retrieving service information on web services.
• Web services use data-centric XML documents to communicate information.
Grid Computing, B. Wilkinson, 2004 3a.9
Web Services “Stack”
• HTTP transport
• SOAP message carrying XML documents
• WSDL (Web Services Description Language used to describe message syntax for invoking a service and its response.
• UDDI (Universal Description, Discovery and Integration) used as web service discovery mechanism.
Grid Computing, B. Wilkinson, 2004 3a.10
Web Services “Stack”
+ XML
Grid Computing, B. Wilkinson, 2004 3a.11
Web Services
From http://www.globus.org
1
23
45
6
Grid Computing, B. Wilkinson, 2004 3a.12
Simple Object Access Protocol (SOAP)
A communication protocol for passing XML documents. Provides mechanisms for:
– Defining communication unit - a SOAP message– Error handling– Extensions– Data representation– Remote Procedure Calls (RPC’s)– Document-centric approach for business transactions– Binding to HTTP
Grid Computing, B. Wilkinson, 2004 3a.13
SOAP Envelope<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>
namespace,see later
Grid Computing, B. Wilkinson, 2004 3a.14
What goes down the Wire
HTTP packet containing:– Stuff about context, transactions, routing,
reliability, security– SOAP message– Attachments
XML/SOAP standardization body, World Wide Web Consortium (W3C) covers SOAP and attachments.
Grid Computing, B. Wilkinson, 2004 3a.15
Structure of an XML document
• Optional Prolog
• Root Element
Grid Computing, B. Wilkinson, 2004 3a.16
Prolog
• Includes processing instruction (<? … ?>) to specify how to process document..
• Includes meta-information about document, and comments.
Grid Computing, B. Wilkinson, 2004 3a.17
• One PI identifies document as a XML document, e.g.
<?xml version=“1.0” encoding=“UTF-8”?>
• Comments, same form as HTML:
<!-- this is a comment -->
Grid Computing, B. Wilkinson, 2004 3a.18
Root element
• Root element contains contents of document.
• Other elements are within root element and can be nested.
Grid Computing, B. Wilkinson, 2004 3a.19
XML Tags
• Not predefined as in HTML.
• Must define your own tags using names as names in a programming languages
• As in programming languages, restrictions. Case sensitive. Start with a letter.
• “Elements” have start and end tags.
• Start tags can have attributes as in HTML.
Grid Computing, B. Wilkinson, 2004 3a.20
Namespace Mechanism
• If XML documents combined, can be problem if different documents use the same tag names to mean different things.
• With namespace mechanism, tags given additional namespace identifier to qualify it.
Grid Computing, B. Wilkinson, 2004 3a.21
Qualifying names
• Qualified name given by namespace identifier and name used in document:
Qualified name = namespace identifier + local name
Grid Computing, B. Wilkinson, 2004 3a.22
Namespace identifier
• Uses URI’s (Uniform Resource Identifiers) - web naming mechanism.
• URLs are a subset of URI, and would typically be used, e.g.:
http://www.cs.wcu.edu/~abw/ns
Grid Computing, B. Wilkinson, 2004 3a.23
URIs also include email addresses, i.e.
mailto:[email protected]
and
Uniform Resource Names (URNs) which are globally unique and persistent. UDDI uses URNs.
Grid Computing, B. Wilkinson, 2004 3a.24
Associating namespace identifier with local name
• Names in document given a prefix, i.e.:<mypo:street>
• Namespace identifier associated with prefix in root element::
xmlns:po=“http://www.cs.wcu.edu/~abw/ns”
Grid Computing, B. Wilkinson, 2004 3a.25
Namespace Example
<mypo:po xmlns:mypo=“http://www.cs.wcu.edu/~abw/ns”>
<mypo:description>
Computer, Pentium IV, 2.8 Ghz, 4 Gbytes main memory
</mypo:description>
</mypo:po>
prefix
Grid Computing, B. Wilkinson, 2004 3a.26
Can apply namespace to every tag without a prefix automatically if that is required:
<mypo:po xmlns=“http://www.cs.wcu.edu/~abw/ns”>
<description>
Computer, Pentium IV, 2.8 Ghz, 4 Gbytes main memory
</description>
</mypo:po>
Grid Computing, B. Wilkinson, 2004 3a.27
Defining Legal XML Tags
• Legal tags in a document defined optionally using either:
– Document type definitions (DTD) within document. <!DOCTYPE …. > (old, not allowed with SOAP).
or– XML schema
Grid Computing, B. Wilkinson, 2004 3a.28
XML Schema
• Flexible way of handing legal element names. Expressed in XML.
• Schema is an XML document with required definitions.
• Handles namespaces.
• Has notation of data types
Grid Computing, B. Wilkinson, 2004 3a.29
XML schema
Document
xsi:schemaLocation=“ .. “
Grid Computing, B. Wilkinson, 2004 3a.30
XML Schema StructureExample
<?xml version=“1.0” encoding=“UTF-8”?>
<xsd:schema xmlns=“http://www.skatestown.com/ns/po”
xmlns:xsd=“http://www.w3.org/2001/XMLSchema”
targetNamespace=http://www.skatestown.com/ns/po”>
<xsd:annotations>
<xsd:documentation xml:lang=“en”>
Purchase order schema for SkatesTown.
</xsd:documentation>
</xsd:annotation>.
.
.
</xsd:schema>From: “Building Web Services with Java, making sense of XML, SOAP, WSDL, and UDDI, 2nd ed”
by S. Graham et al, SAMS publishing, 2004, p 54.
Grid Computing, B. Wilkinson, 2004 3a.31
Associating schema to documentExample
<?xml version=“1.0” encoding=UTF-8”?>
<po:po xmlns:po=“http://www.skatestown.com/ns/po”
xmlns:xsi=“http://www.w3.org/2001/XMLSchema-instance”
xsi:schemaLocation=“http://www.skatestown.com/ns/po
http://www.skatestown.com/schema/po.xsd”
id=“43871” submitted=“2001-10-05”>.
.
.
</po:po>
From: “Building Web Services with Java, making sense of XML, SOAP, WSDL, and UDDI, 2nd ed” by S. Graham et al, SAMS publishing, 2004, p 54.
Grid Computing, B. Wilkinson, 2004 3a.32
Additional XML materialsOn-line materials
• W3C consortium home page:
http://www.w3.org/XML/
• W3Schools XML Tutorial :
http://www.w3schools.com/xml/
Grid Computing, B. Wilkinson, 2004 3a.33
Books
Several books on XML, e.g.:
“Building Web Services with Java: Making sense of XML, SOAP, WSDL, and UDDI, 2nd edition”
by S. Graham et al, SAMS publishing, 2004
Very good but 792 pages!!
Grid Computing, B. Wilkinson, 2004 3a.34
Additional SOAP materials
See:
http://www.w3c.org/TR/soap
Grid Computing, B. Wilkinson, 2004 3a.35
Hosting Environments for Web Services
• Microsoft .NET
• IBM Websphere
• Apache Axis - we will be using this for assignment 1
Grid Computing, B. Wilkinson, 2004 3a.36
More information on Axis
http://xml.apache.org/axis