360 likes | 512 Views
WEB SERVICES Introduction. Web Services. Software components designed to provide specific operations (“services”) accessible using standard Internet technology. For machine interaction over a network.
E N D
WEB SERVICESIntroduction Grid Computing, B. Wilkinson, 2004
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
Basic client-server model Grid Computing, B. Wilkinson, 2004
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
Service-Oriented Architecture Steps: • 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
Service-Oriented Architecture Service registry 1. Publish 2. Find 3. Bind Service requester Service provider Grid Computing, B. Wilkinson, 2004
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
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
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
Web Services “Stack” + XML Grid Computing, B. Wilkinson, 2004
Web Services 1 3 2 4 5 6 From http://www.globus.org Grid Computing, B. Wilkinson, 2004
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
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
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
Structure of an XML document • Optional Prolog • Root Element Grid Computing, B. Wilkinson, 2004
Prolog • Includes processing instruction (<?…?>) to specify how to process document.. • Includes meta-information about document, and comments. Grid Computing, B. Wilkinson, 2004
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
Root element • Root element contains contents of document. • Other elements are within root element and can be nested. Grid Computing, B. Wilkinson, 2004
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
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
Qualifying names • Qualified name given by namespace identifier and name used in document: Qualified name = namespace identifier + local name Grid Computing, B. Wilkinson, 2004
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
URIs also include email addresses, i.e. mailto:abw@email.wcu.edu and Uniform Resource Names (URNs) which are globally unique and persistent. UDDI uses URNs. Grid Computing, B. Wilkinson, 2004
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
Namespace Example prefix <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> Grid Computing, B. Wilkinson, 2004
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
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
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
XML schema Document xsi:schemaLocation=“ .. “ Grid Computing, B. Wilkinson, 2004
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
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
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
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
Additional SOAP materials See: http://www.w3c.org/TR/soap Grid Computing, B. Wilkinson, 2004
Hosting Environments for Web Services • Microsoft .NET • IBM Websphere • Apache Axis - we will be using this for assignment 1 Grid Computing, B. Wilkinson, 2004
More information on Axis http://xml.apache.org/axis Grid Computing, B. Wilkinson, 2004