Web Services Introduction | 13.06.2007 | Folie 2Regionales Rechenzentrum für Niedersachsen
Outline
Web Service introductionService Oriented ArchitecturePractical examplesBasic of Extensible Markup Language (XML)
DTDSchema
UDDI – Publishing Web ServicesWSDL – A formal language to describe Web ServicesSOAP – Accessing Web ServicesExample from www.xmethods.comSome challenges of the Web Service Technologie
Web Services Introduction | 13.06.2007 | Folie 3Regionales Rechenzentrum für Niedersachsen
Web Services – A Description
„ Web service is a piece of software, which provide functionality as blackbox, available on server, accessible via a simple object access protocol and has a well-defined interface“ An example is Google without browser .
Web Services Introduction | 13.06.2007 | Folie 4Regionales Rechenzentrum für Niedersachsen
Why Web Services?
Transactional web is desired
Convert applications into web applications
Interaction between different systems is needed
Web services can perform functions which can be anything from a simple request to a complicated business process (weather reports, Amazon, etc)
Web services are self-contained and self-describing
Using a service-oriented architecture to provide business services accessed by other applications
Web Services Introduction | 13.06.2007 | Folie 5Regionales Rechenzentrum für Niedersachsen
SOA – Service Oriented Architecture (1)
Provider– Implements and publishes a web service (WSDL)– Provides the service to customers (SOAP)
Broker– Holds a list of published web services (UDDI)– Provides a dynamic search functionality for requesters (UDDI)
Requester– Searches for a specific web service in the broker's list (WSDL)– Establishes a connection with the provider and uses the service (SOAP)
Requester Broker
Provider
Find
Bind Publish
WSDL
UDDI
WSDLSOAP
Web Services Introduction | 13.06.2007 | Folie 6Regionales Rechenzentrum für Niedersachsen
Web Services (Examples)
Book a flightSouth West Airline connects its own booking system with the one of Dollar Car Rentals
using Dollar Car's Web ServiceA customer booking a flight over the South West homepage can book a car together
with the flight without leaving the South West website
Restaurant guide for PDAsMakes suggestions of restaurants for a user based on the user's profileCalls the Web Service of www.mapquest.com to provide directions to the restaurants
Web Services Introduction | 13.06.2007 | Folie 7Regionales Rechenzentrum für Niedersachsen
Web Service - Requirements
A mechanism to allow document transfer
Possibility to make Remote Procedure Calls (RPCs)
An easy protocol
Platform independency
Ability to be processed by common programming languages
A formal, standardized language to allow communication between the different roles
Regionales Rechenzentrum für Niedersachsen
XML – Extensible Markup Language
Unlike HTML, XML is used to describe data and not to display it
Currently the lingua franca of information and data encoding
Cross-platform, soft- and hardware independent tool for exchanging information
A meta language for creating xml-based mark-up languages (SGML)
Classification of XML languagesData oriented languages (database systems)Document oriented languages (WML)Protocols and programming languages (XSD, XSLT, WSDL , etc.)Hybrids (data and document oriented)
Web Services Introduction | 13.06.2007 | Folie 9Regionales Rechenzentrum für Niedersachsen
XML namespaces
Using URIs to identify different name spacesThe cheapest way of getting unique names and avoiding confusions.
<widget type=“gadget“> <head size=“medium“/> <info> <head> <title> description
of gadget </title> </head> <body> … </body> </info></widget>
<widget type=“gadget“ xmlns=“http://www.widget.inc“>
<head size=“medium“/> <info
xmlns:xhtml=“http://www.w3....“> <xhtml:head> <xhtml:title>
description of gadget </xhtml:title> </xhtml:head> <xhtml:body>
… </xhtml:body> </info></widget>
Regionales Rechenzentrum für Niedersachsen
XML syntax
Syntax: very simple and very strict (well-formed)each document has a root element, which in turn has child elements
Land
Forrest Meadow
Tree Tree Tree
<LAND> <FOREST> <TREE>Oak</TREE> <TREE>Pine</TREE> <TREE>Maple </TREE> </FOREST> <MEADOW> <GRASS>Bluegrass</GRASS> <GRASS>Fescue</GRASS> <GRASS>Rye</GRASS> </MEADOW> </LAND
Web Services Introduction | 13.06.2007 | Folie 11Regionales Rechenzentrum für Niedersachsen
XML syntax: DTD (Data Type Definition)
A schema language for defining the grammar and restrictions over data for the XML document
Basic declaration forms in example:
<!DOCTYPE land SYSTEM “http://www.nature.dk/land.dtd”><!ELEMENT land (forest, meadow)><!ELEMENT forest (tree*)><!ELEMENT meadow (#PCDATA)>
<?xml version=1.1”?><!DOCTYPE land SYSTEM=“http://.../land.dtd>
<land> <forest> <tree>. . . </tree> <tree>. . . </tree> </forest></land>
<?xml version=1.1”?><!DOCTYPE land SYSTEM=”http://.../land.dtd
<land> <meadow> <tree>. . .</tree> <tree>. . . </tree> </meadow></land>
Valid Not Valid
Web Services Introduction | 13.06.2007 | Folie 12Regionales Rechenzentrum für Niedersachsen
XML syntax: DTD (Data Type Definition)
Pros A simple schema language with a restricted expressive power
Cons character data limitation limited reusability no namespaces supported not self describable not scalable
Web Services Introduction | 13.06.2007 | Folie 13Regionales Rechenzentrum für Niedersachsen
XML syntax: XSD (XML Schema Definition)
One of the key komponents of XML Overcome DTD limitations (more expressive, self describing and
namespaces supporting)
Inspired from object-oriented programming languages (reuse&comprehensibility) Global as well as local declarations Modularization Nil values in Elements annotations(human readable documentation) subsumption and substitution(xsi:type attribute)
The most central constructs in XSD:1. Simple type definition2. Complex type definition3. Element declaration4. Attribute declaration
Regionales Rechenzentrum für Niedersachsen
XSD - Example
<schema xmlns=“http://www.w3.org/2001/XMLSchema” xmlns:b=“http://businesscard.org targetNamespace=“http://businesscard.org”>
<element name=“card” type=“b:card_type”/><element name=“name” type=“string”/><element name=“phone” type=“string”/><element name=“logo” type=“b:logo_type”/><attribute name=“uri” type=“anyURI”><complexType name=“card_type”> <sequence>
< element ref=“b:name”/> < element ref=“b:phone” minoccurs=“0”/> < element ref=“b:logo” minoccurs=“0”/></sequence>
</complexType><complexType name=“logo_type”> <attribute ref=“b:uri” use=“required”/></complexType>
<schema>
Web Services Introduction | 13.06.2007 | Folie 15Regionales Rechenzentrum für Niedersachsen
XML Schema (1)
Pros More expressive than DTD Self described Namespace support Written in XML Reusable & comprehensibility More flexible
Cons Too complicated and hard to use (Type mechanism) Context insensitivity – typical problem in XML languages Difficult to enforce a particular root element
Web Services Introduction | 13.06.2007 | Folie 16Regionales Rechenzentrum für Niedersachsen
XML Schema (2)
Common approach to overcome these problems(guidelines)Example:guildlines of „Danish ministry of science“
Always employ namespaces Use global definitions Reuse existing definitions whenever possible Don´t use the list construct Avoid substitution groups Don´t use unqualified local elements
and many more.
Web Services Introduction | 13.06.2007 | Folie 17Regionales Rechenzentrum für Niedersachsen
UDDI – Universal Description Discovery and Integration
Requester
Broker
Provider
Find
BindPublish
WSDL
UDDI
WSDLSOAP
Web Services Introduction | 13.06.2007 | Folie 18Regionales Rechenzentrum für Niedersachsen
UDDI – Universal Description Discovery and Integration
UDDI is an XML-based, platform-independent registry allows businesses worldwide to publish their services and find usefull services
provided by other companiesA UDDI can be thought of as a DNS for business applicationshas a SOAP interface
Two main goals for service discoverySupport developers in finding information about services, so they know how to write
clients which can interact with those servicesEnable dynamic binding by allowing clients to query the registry and obtain references
to services of interest
An UDDI business registration consists of three componentsWhite Pages – Basic information like name, address, unique identifierYellow Pages – Categorizes the registered businessesGreen Pages – Technical information describing the provided services and how they
can be invoked
Web Services Introduction | 13.06.2007 | Folie 19Regionales Rechenzentrum für Niedersachsen
UDDI – Data types
<businessEntity>
• Name, contact, description
• Identifier and category
<publisherAssertion>
• Connection between two companies
<businessService>
• Grouping of logical services
<bindingTemplate>
• Technical information of a single Web Service
• URL-Accesspoint for this Service
<tModel>
• Specification implemented by the Web Service
• Links pointing to the specifications
Web Services Introduction | 13.06.2007 | Folie 20Regionales Rechenzentrum für Niedersachsen
WSDL
RequesterBroker
Provider
Find
Bind
Publish
WSDL
UDDI
WSDL
SOAP
Web Services Introduction | 13.06.2007 | Folie 21Regionales Rechenzentrum für Niedersachsen
WSDL
WSDL WSDL is a platform-, protocol and programming language independent XML-
Specification to describe Web Services Is a Meta language Describes the provided functions, data and types
A WSDL document contains information about the provided interface the protocol which must be used how the service can be accessed
The document does not contain information about Quality-of-Service-Information Taxonomy/Ontology for semantic description of the service
Web Services Introduction | 13.06.2007 | Folie 22Regionales Rechenzentrum für Niedersachsen
WSDL – Description elements
DatatypesDefinition of the datatypes, which are used to exchange the message
MessageAn abstract definition of the transported data
Port typesDefine the operations so that the Web Service knows how to interpret the data and
what kind of data has to be returned4 different types of exchanged messages
One-way: The service receives an input message from the clientRequest-Response: The service receives an input message from the client and sends an
answerSolicit-response: The service sends a message to the client and waits for a responseNotification: The service sends an output message
BindingDefines the concrete protocol for every port type
PortsDefines an address for the binding. Usually an URI
Service Identifies a Web Service
Web Services Introduction | 13.06.2007 | Folie 23Regionales Rechenzentrum für Niedersachsen
WSDL – An example (1)
Book price at Barnes & Nobles by ISBN
<wsdl:types><s:schema elementFormDefault="qualified" targetNamespace="http://www.abundanttech.com/webservices/BNPrice"><s:element name="GetBNQuote">
<s:complexType><s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="sISBN" type="s:string"/>
</s:sequence></s:complexType>
</s:element><s:element name="GetBNQuoteResponse">
<s:complexType><s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="GetBNQuoteResult" type="s:string"/>
</s:sequence></s:complexType>
</s:element><s:element name="string" nillable="true" type="s:string"/></s:schema></wsdl:types>
Web Services Introduction | 13.06.2007 | Folie 24Regionales Rechenzentrum für Niedersachsen
WSDL – An Example (2)
<wsdl:message name="GetBNQuoteSoapIn"><wsdl:part name="parameters" element="tns:GetBNQuote"/>
</wsdl:message><wsdl:message name="GetBNQuoteSoapOut">
<wsdl:part name="parameters" element="tns:GetBNQuoteResponse"/></wsdl:message>
<wsdl:portType name="BNPriceWSSoap"><wsdl:operation name="GetBNQuote">
<wsdl:input message="tns:GetBNQuoteSoapIn"/><wsdl:output message="tns:GetBNQuoteSoapOut"/>
</wsdl:operation></wsdl:portType>
<wsdl:binding name="BNPriceWSSoap" type="tns:BNPriceWSSoap"><soap:binding transport="http://schemas.xmlsoap.org/soap/http”/>
<wsdl:operation name="GetBNQuote"><soap:operation
soapAction="http://.../GetBNQuote" /><wsdl:input>
<soap:body use="literal"/></wsdl:input><wsdl:output>
<soap:body use="literal"/></wsdl:output>
</wsdl:operation></wsdl:binding>
Web Services Introduction | 13.06.2007 | Folie 25Regionales Rechenzentrum für Niedersachsen
WSDL – An Example (3)
<wsdl:service name="BNPriceWS"><wsdl:port name="BNPriceWSSoap"
binding="tns:BNPriceWSSoap"><soap:address location="http://.../bnprice/bnprice.asmx"/>
</wsdl:port><wsdl:port name="BNPriceWSHttpGet"
binding="tns:BNPriceWSHttpGet"><http:address location="http://.../bnprice/bnprice.asmx"/>
</wsdl:port><wsdl:port name="BNPriceWSHttpPost"
binding="tns:BNPriceWSHttpPost"><http:address location="http://.../bnprice/bnprice.asmx"/>
</wsdl:port></wsdl:service>
Web Services Introduction | 13.06.2007 | Folie 26Regionales Rechenzentrum für Niedersachsen
WSDL
ProsIndependency between client and serverProgramming language independentPlenty of tools available for processing WSDL documents (code generators like
wsdl2java)
ConsOverhead because of XML
Regionales Rechenzentrum für Niedersachsen
SOAP
Requester Broker
Provider
Find
Bind Publish
WSDL
UDDI
WSDLSOAP
Web Services Introduction | 13.06.2007 | Folie 28Regionales Rechenzentrum für Niedersachsen
SOAP – Simple Object Access Protocol (1)
Is not simpleSince version 1.2 the abbreviation is no longer used as an acronym because SOAP
is not simple and has nothing to do with accessing objects
Is a framework Sets no rules about the data which should be sentAny application specific data can be transportedSOAP provides a ruleset to define how the XML-Document must look like
Based on existing technologiesXML to describe the data Internet protocols to transport the dataCommon combination is SOAP over HTTP and TCP
Network protocol which allows transfer of documents between systems to call procedures on remote systems (Remote Procedure Calls, RPCs)
Web Services Introduction | 13.06.2007 | Folie 29Regionales Rechenzentrum für Niedersachsen
SOAP – Simple Object Access Protocol (2)
A SOAP message consists of An SOAP-Envelope, the root element An optional SOAP-Header with processing instructions The SOAP-Body containing the data
SOAP in the TCP/IP Protocol stack
ApplicationSOAP
Transport
Network
HTTP HTTPS ...
TCP
IP
Web Services Introduction | 13.06.2007 | Folie 30Regionales Rechenzentrum für Niedersachsen
XML to SOAP
<?xml version=‘1.0’ encoding=‘UTF-8’ ?> <SOAP-ENV:Envelope
xmlns:SOAP-ENV=‘http://schemas.xmlsoap.org/soap/envelope/’xmlns:xsi=‚http://www.w3.org/1999/XMLSchema-instance‘xmlns:xsd=‚http://www.w3.org/1999/XMLSchema‘>
<SOAP-ENV:Header>…
</SOAP-ENV:Header> <SOAP-ENV:Body> <PurchaseOrder xmlns=„urn:oreilly-jaws-samples“><shipTo country=„US“>
<name>Joe Smith</name><street>14 Oak Park</street>…
</shipTo><items>
<item>…</item></items>
</PurchaseOrder> </SOAP-ENV:Body> </SOAP-Env:Envelope>
Eigentliches XML-Dokument
Web Services Introduction | 13.06.2007 | Folie 31Regionales Rechenzentrum für Niedersachsen
SOAP – Remote Procedure Call
Call of a service which returns the price of a book at Barnes & Nobles by a given ISBN:
<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body>
<GetBNQuote xmlns="http://www.abundanttech.com/webservices/BNPrice"> <sISBN>0130449687</sISBN>
</GetBNQuote>
</soap:Body></soap:Envelope>
<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://.../soap/envelope/">
<soap:Body> <GetBNQuoteResponse xmlns="http://.../BNPrice">
<GetBNQuoteResult>49.99</GetBNQuoteResult> </GetBNQuoteResponse>
</soap:Body> </soap:Envelope>
Response:
http://www.abundanttech.com/webservices/bnprice/bnprice.asmx
Web Services Introduction | 13.06.2007 | Folie 32Regionales Rechenzentrum für Niedersachsen
SOAP
ProsAllows the use of different transport protocols (HTTP, FTP, etc.)HTTP makes communication behind proxies and firewalls easierXML is simple to parse and widely spreadEasy interaction with a lot of programming languages
ConsUsing XML in SOAP leads to more overhead and slower trafficMany SOAP implementations limit the amount of exchanged data
Web Services Introduction | 13.06.2007 | Folie 33Regionales Rechenzentrum für Niedersachsen
Using a Web Service – Step 1
www.xmethods.com
Web Services Introduction | 13.06.2007 | Folie 34Regionales Rechenzentrum für Niedersachsen
Using a Web Service – Step 2
Web Services Introduction | 13.06.2007 | Folie 35Regionales Rechenzentrum für Niedersachsen
Challenges
Integrating the semantic web specification into Web Services (semantic web annotations group)
Getting Web Services to the point that they can be found and used by applications without human interactionBased on XML WSDL and SOAP are machine readable and processable
More security in Web Services
Delivering a suitable Web Service for the user‘s need (ranking problem)
Web Services Introduction | 13.06.2007 | Folie 36Regionales Rechenzentrum für Niedersachsen
Summary
Web ServicesSOAXMLUDDIWSDLSOAPExamplesChallenges
Web Services Introduction | 13.06.2007 | Folie 37Regionales Rechenzentrum für Niedersachsen
Sources
XMLAn introduction to xml and web technologies; Anders Miller, Michael I.
Schwartzbach; Addison Wesley; (Link)http://www.comptechdoc.org/independent/web/xml/guide/http://webservices.xml.com/index.csphttp://www.developer.com/http://www.ibm.com/us/http://www.w3schools.com
Web ServicesJava Web Services; David A. Chappell, Tyler Jewell; O‘Reilly; (Link)http://www.w3.org/2002/ws/http://www.xmethods.com
Some more intresting linkshttp://www.soapclient.com/uddisearch.htmlhttp://www.amazon.com/gp/browse.html?node=3435361http://code.google.com/