Web services part i '/>
This presentation is the property of its rightful owner.
Sponsored Links
1 / 40

Web Services – Part I PowerPoint PPT Presentation


  • 75 Views
  • Uploaded on
  • Presentation posted in: General

Web Services – Part I. CS 236607, Spring 2008/9. What is a Web Service?. Web Service: "Web services are loosely coupled software components delivered over Internet standard technologies." “Software that makes services available on a network using technologies such as XML and HTTP”

Download Presentation

Web Services – Part I

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Web services part i

Web Services – Part I

CS 236607, Spring 2008/9


What is a web service

What is a Web Service?

  • Web Service:

    • "Web services are loosely coupled software components delivered over Internet standard technologies."

    • “Software that makes services available on a network using technologies such as XML and HTTP”

  • Service-Oriented Architecture (SOA):

    • “Development of applications from distributed collections of smaller loosely coupled service providers”

  • Web services support service-oriented architectures, using in particular XML and HTTP.


What is a web service cont

What is a Web Service? (Cont.)

  • Self-contained, modular Web application that can be published, located and invoked across the Web

  • A Web service can perform functions of varying complexities.

  • Once deployed, other applications (and other Web services) can discover and invoke the deployed service


Why a new framework

Why a New Framework?

  • CORBA, DCOM, Java/RMI, ... already exist

  • XML+HTTP: platform neutral, widely accepted and utilized


Example scenario online trade

The Hobbit (5)

Price: 20.95

Copies in Stock: 5

The Hobbit (5)

Price: 20.95

Copies in Stock: 4

Buy The Hobbit (5)

How Much?

Buy it

Book Store

Buy The Hobbit (5)

20.95

The Hobbit (5)

Price: 25.95

Copies in Stock: 1

The Hobbit (5)

Price: 25.95

Copies in Stock: 0

Example Scenario – Online Trade

Book Store

The Hobbit (5)

Price: 25.95

Copies in Stock: 1

The Hobbit (5)

Price: 25.95

Copies in Stock: 0


Why is it difficult to use ordinary web sites as services

Why is it Difficult to Use Ordinary Web Sites as Services?

  • Consider an application that should return the price of the book “The Hobbit”

    • The application needs to fill the required form and launch a “browser-like” request

    • The application needs to parse the page, based on its specific HTML structure, and retrieve the price

    • Once the Web site changes its user interface, your program is useless

    • How can we find new online stores?


Web services part i

How can we find this URL?

What is the price here?


Calling remote functions could help

Calling Remote Functions Could Help

  • It would help if we could call functions, such as:

    • Amazon.getPrice(“The Hobbit")

    • Amazon.buyBook(“The Hobbit", myId)

getPrice(…)

The

Internet


Difficulties in using remote functions

Difficulties in Using Remote Functions

  • For each remote function, we need to phrase a call in the specific language that is used for its implementation

  • For each remote function, we need to contact the provider in order to find out what exactly the signature (i.e., parameters, return value, inc. the type) is

  • On the server side, each remote function needs to listen to a server socket bound to a specific port

    • Not in line with protection by firewalls


A solution

A Solution

  • Use an agreed interface and a syntax that all applications are familiar with (e.g., XML)

    • For example, SOAP

  • Use HTTP to transfer data through port 80

  • Use a standard for publishing methods, their signatures and their usage

    • For example, WSDL

  • Use standard directory structures for publishing available services

    • For example, UDDI


Available web services examples

Available Web Services Examples

  • http://seekda.com/

  • Google search (http://www.google.com/apis)

  • Weather reports

  • Stock prices

  • Currency exchanges

  • Sending SMS messages, faxes

  • Prices of books in Barnes and Nobles

  • Dictionaries

  • And more…


Essential technologies

SERVICE

REGISTRY

find

publish

SERVICE

PROVIDER

SERVICE

USER (Client)

messages

Essential Technologies

A range of protocols has been suggested in the last years. We will discuss what are commonly believed to be the essential technologies:

  • SOAP – exchanging XML messages on a network

  • WSDL – describing interfaces of Web services

  • UDDI – managing registries of Web services


Web services part i

SOAP

Used to be “Simple Object Access Protocol” but no longer an acronym...


What is soap

What is SOAP?

  • SOAP is a protocol for invoking Web Services

  • SOAP is XML based

  • In SOAP, applications may exchange information over HTTP

    • HTTP is just one possible communication pattern supported by SOAP (e.g. SMTP)


Soap envelope

SOAP Envelope

<Envelope xmlns="http://www.w3.org/2003/05/soap-envelope">

<Header>...</Header>

<Body>...</Body>

</Envelope>

  • Envelope Headers:

    • Encryption information

    • Access control

    • Routing

    • ...


Web services part i

<?xml version="1.0" encoding="UTF-8"?>

<soapenv:Envelope

xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"

xmlns:xsd="http://www.w3.org/2001/XMLSchema"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<soapenv:Body>

<ns1:getRate

soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"

xmlns:ns1="urn:xmethods-CurrencyExchange">

<country1 xsi:type="xsd:string">Euro</country1>

<country2 xsi:type="xsd:string">Israel</country2>

</ns1:getRate>

</soapenv:Body>

</soapenv:Envelope>

A request to services.xmethods.net:80


Web services part i

<?xml version='1.0' encoding='UTF-8'?>

<soap:Envelope

xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'

xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'

xmlns:xsd='http://www.w3.org/2001/XMLSchema'

xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/'

soap:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'>

<soap:Body>

<n:getRateResponse

xmlns:n='urn:xmethods-CurrencyExchange'>

<Result xsi:type='xsd:float'>5.5825</Result>

</n:getRateResponse>

</soap:Body>

</soap:Envelope>

The Response


A soap message

A SOAP Message

  • A SOAP message is an ordinary XML document containing the following elements:

    • Envelope – identifies the XML document as a SOAP message: required

    • Header – contains header information: optional

    • Body – contains call or response information: required

    • Fault – provides information about errors that occurred while processing the message: optional


Special soap header attributes

Special SOAP Header Attributes

INTERMEDIARY

INTERMEDIARY

  • role

INITIAL

SENDER

  • mustUnderstand

  • And more

    Example:

ULTIMATE

RECEIVER

INTERMEDIARY

...

<env:Header>

<c:encoding env:role="http://encodings.example.org/decoder"

env:mustUnderstand="true">

gzip+base64

</c:encoding>

</env:Header>

...


Soap response on error

SOAP Response on Error

  • In loosely connected distributed systems many things can go wrong:

    • Invalid data may be transmitted

    • Servers may be unavailable

  • SOAP provides a uniform way to indicate such errors.


Faults example

Faults Example

<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"

xmlns:w="http://www.widget.inc/shop">

<env:Body>

<env:Fault>

<env:Code>

<env:Value>env:Sender</env:Value>

<env:Subcode>

<env:Value>w:InvalidBuyRequest</env:Value>

</env:Subcode>

</env:Code>

<env:Reason>

<env:Text xml:lang="en">

The value of 'amount' is invalid!

</env:Text>

<env:Text xml:lang="da">

Værdien af 'amount' er ugyldig!

</env:Text>

</env:Reason>

</env:Fault>

</env:Body>

</env:Envelope>


Protocol binding

Protocol Binding

  • Transmitting a SOAP message requires a communication protocol to carry the message.

  • This is called SOAP protocol binding .

  • Transmission protocols: HTTP, SMTP, ...

  • Message exchange patterns:

    • request–response (for RPC)  POST

    • SOAP response (Only the response is a SOAP message)  GET

How will we know what

To use?


Web services part i

WSDL

Web Services Description Language


Describing a web service

Describing a Web Service

  • Need a standard way to describe a Web Service:

    • The methods available

    • Their parameters

    • How to communicate

    • Etc.


Describing a web service wsdl answer

Describing a Web Service – WSDL Answer

  • WSDL is a standard for describing Web services using XML.

  • WSDL Can Describe:

    • What a Web service can do

    • Where it resides

    • How to invoke it


Structure of a wsdl description

Structure of a WSDL Description

<description xmlns="http://www.w3.org/2004/08/wsdl"

targetNamespace="..." ...>

<types>

<!-- XML Schema description of types being used

in messages -->

...

</types>

<interface name="...">

<!-- list of operations and their input and output -->

...

</interface>

<binding name="..." interface="..." type="...">

<!-- message encodings and communication protocols -->

...

</binding>

<service name="..." interface="...">

<!-- combination of an interface, a binding,

and a service location -->

...

</service>

</description>


A recipe server with xml and http

A Recipe Server with XML and HTTP

  • Let’s think of a Recipe Server which under an Ad hoc approach, RPC-style, it would have the following functionalities:

    • Recipes getRecipes()

    • Lock lockRecipe(ID)

    • void writeRecipe(Lock,Recipe)

    • void unlockRecipe(Lock)

  • This is how it’s WSDL would look like (The following slides)


Recipe server with wsdl and soap 1 6

Recipe Server with WSDL and SOAP (1/6)

<description xmlns="http://www.w3.org/2004/08/wsdl"

targetNamespace="http://www.brics.dk/ixwt/recipes/wsdl"

xmlns:x="http://www.brics.dk/ixwt/recipes/wsdl">

<types>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"

targetNamespace=

"http://www.brics.dk/ixwt/recipes/wsdl/types"

xmlns:t="http://www.brics.dk/ixwt/recipes/wsdl/types">

<xs:import namespace="http://www.brics.dk/ixwt/recipes"

schemaLocation="recipes.xsd"/>

<xs:element name="lock">

<xs:simpleType>

<xs:restriction base="xs:string">

<xs:length value="16"/>

</xs:restriction>

</xs:simpleType>

</xs:element>


Recipe server with wsdl and soap 2 6

Recipe Server with WSDL and SOAP (2/6)

<xs:element name="lockError" type="xs:string"/>

<xs:element name="getRecipes">

<xs:complexType><xs:sequence/></xs:complexType>

</xs:element>

<xs:element name="lockRecipe">

<xs:complexType>

<xs:sequence>

<xs:element name="id" type="xs:NMTOKEN"/>

</xs:sequence>

</xs:complexType>

</xs:element>

<xs:element name="lockRecipeResponse">

<xs:complexType>

<xs:sequence>

<xs:element ref="t:lock"/>

</xs:sequence>

</xs:complexType>

</xs:element>


Recipe server with wsdl and soap 3 6

Recipe Server with WSDL and SOAP (3/6)

<xs:element name="writeRecipe">

<xs:complexType>

<xs:sequence>

<xs:element ref="t:recipe"/>

<xs:element ref="t:lock"/>

</xs:sequence>

</xs:complexType>

</xs:element>

<xs:element name="unlockRecipe">

<xs:complexType>

<xs:sequence>

<xs:element ref="t:lock"/>

</xs:sequence>

</xs:complexType>

</xs:element>

</xs:schema>

</types>


Recipe server with wsdl and soap 4 6

Recipe Server with WSDL and SOAP (4/6)

<interface name="recipeserverInterface"

xmlns:t="http://www.brics.dk/ixwt/recipes/wsdl/types"

styleDefault="http://www.w3.org/2004/03/wsdl/style/rpc">

<fault name="lockFault" element="t:lockError"/>

<operation name="getRecipesOperation"

pattern="http://www.w3.org/2004/03/wsdl/in-out">

<input messageLabel="In" element="t:getRecipes"/>

<output messageLabel="Out" element="t:collection"/>

</operation>

<operation name="lockRecipeOperation"

pattern="http://www.w3.org/2004/03/wsdl/in-out">

<input messageLabel="In" element="t:lockRecipe"/>

<output messageLabel="Out"

element="t:lockRecipeResponse"/>

<outfault ref="x:lockFault" messageLabel="Out"/>

</operation>


Recipe server with wsdl and soap 5 6

Recipe Server with WSDL and SOAP (5/6)

<operation name="writeRecipeOperation"

pattern=

"http://www.w3.org/2004/03/wsdl/robust-in-only">

<input messageLabel="In" element="t:writeRecipe"/>

<outfault ref="x:lockFault"/>

</operation>

<operation name="unlockRecipeOperation"

pattern="http://www.w3.org/2004/03/wsdl/in-only">

<input messageLabel="In" element="t:lock"/>

</operation>

</interface>


Recipe server with wsdl and soap 6 6

Recipe Server with WSDL and SOAP (6/6)

<binding name="recipeserverSOAPBinding"

interface="x:recipeserverInterface"

type="http://www.w3.org/2004/08/wsdl/soap12"

xmlns:ws="http://www.w3.org/2004/08/wsdl/soap12"

ws:protocol="http://www.w3.org/2003/05/soap/bindings/HTTP"

ws:mepDefault=

"http://www.w3.org/2003/05/soap/mep/request-response"

xmlns:soap="http://www.w3.org/2003/05/soap-envelope">

<fault ref="x:lockFault" ws:code="soap:Sender"/>

</binding>

<service name="recipeserver"

interface="x:recipeserverInterface">

<endpoint name="recipeserverEndpoint"

binding="x:recipeserverSOAPBinding"

address=

"http://www.widget.inc/personal/jdoe/recipeserver"/>

</service>

</description>


To put it briefly

To Put It Briefly…

  • This particular WSDL description tells us that there is a Web service at the URI http://www.widget.inc/personal/jdoe/recipeserver

  • It understands the RPC-style operations getRecipes, lockRecipe, writeRecipe, and unlockRecipe

  • The communication uses SOAP with the SOAP HTTP binding

  • Certain faults may occur

  • And input and output values are required to be valid according the given schema definitions.


Web services part i

UDDI

Universal Description, Discovery, and Integration


A telephone book

A Telephone Book

  • How can you find a Web service?

  • How can you register your Web service so that others will find it?

  • UDDI is a mechanism for registering and discovering Web services.

  • Think of UDDI as a telephone book


More about uddi

More about UDDI

  • UDDI has grown from the equivalent of a simple yellow pages directory to a framework for brokering collaboration between Web services.

  • For the applications we have considered so far, an external Web service would typically be discovered manually by the programmer and be hardwired into the application. This is known as static discovery.

  • UDDI also targets dynamic discovery, where the application itself at runtime finds a required Web service selected on the basis of, for example, price, availability, or efficiency.


More about uddi cont

More about UDDI (Cont.)

  • UDDI has as yet few applications, compared to the more widespread use of SOAP and WSDL, and most available case studies only consider static discovery.


Summary

Summary

  • SOAP – A protocol for exchanging XML messages on a network (focusing on HTTP)

  • WSDL – A language for describing Web services interfaces.

  • UDDI – A system for managing registries of Web services


Resources

Resources

  • An Introduction to XML and Web Technologies / Anders Møller and Michael I. Schwartzbach – course literature

  • W3C’s SOAP Specifications

  • W3C’s WSDL Specifications

  • UDDI

  • The Web Service Interoperability Organization

  • HU


  • Login