web services distributed computing 9 sep,2008 shahid mahmood

46
Web Services Web Services Distributed Computing 9 Sep,2008 Shahid Mahmood

Upload: vernon-elliott

Post on 25-Dec-2015

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Web Services Distributed Computing 9 Sep,2008 Shahid Mahmood

Web ServicesWeb Services

Distributed Computing9 Sep,2008

Shahid Mahmood

Page 2: Web Services Distributed Computing 9 Sep,2008 Shahid Mahmood

ServiceServiceA service is a function that is

well-defined, self-contained, and does not depend on the context or state of other services

Page 3: Web Services Distributed Computing 9 Sep,2008 Shahid Mahmood

What’s Web Service?What’s Web Service?“Software application identified by a URI, whose

interfaces and bindings are capable of being defined, described, and discovered as XML artifacts” – W3C Web Services Architecture Requirements, Oct. 2002

“Programmable application logic accessible using Standard Internet Protocols…” – Microsoft

“An interface that describes a collection of operations that are network accessible through standardized XML messaging …” – IBM

“Software components that can be spontaneously discovered, combined, and recombined to provide a solution to the user’s problem/request … “ - SUN

Page 4: Web Services Distributed Computing 9 Sep,2008 Shahid Mahmood

Web Services: The Next Web Services: The Next Horizon for e-businessHorizon for e-businessAllow companies to reduce the cost

of doing e-business, to deploy solutions faster◦Need a common program-to-

program communications modelAllow heterogeneous applications to

be integrated more rapidly, easily and less expensively

Facilitate deploying and providing access to business functions over the Web

Page 5: Web Services Distributed Computing 9 Sep,2008 Shahid Mahmood

Web Service InterfaceWeb Service InterfaceA web service interface generally

consists of a collection of operations that can be used by the client over the internet.

A web service may either be managed by a web server along with the web pages or it may be totally separate service.

Web Servers such as Google, Amazon, Yahoo, eBay provides web service interfaces to manipulate their resources

Page 6: Web Services Distributed Computing 9 Sep,2008 Shahid Mahmood

Web services communication Web services communication patternpatternWeb services can process XML-

formatted SOAP messages.An alternative is the

REST(representational state transfer) approach.

Web services communication can be ◦Synchronous/Asynchronous◦Event Based

Page 7: Web Services Distributed Computing 9 Sep,2008 Shahid Mahmood

Combination of web Combination of web servicesservices

hotel booking

Travel Agent

flight booking

hire car bookingServiceClient

flight booking

hotel booking

hire car booking

The ‘travel agent service’ combines other web services

Page 8: Web Services Distributed Computing 9 Sep,2008 Shahid Mahmood

Underlying TechnologiesUnderlying Technologies XML Is the GlueXML Is the Glue

Program the Web

XML

Browse the Web

HTML

TCP/IP

Connect the Web

Technology

Innovation

Connectivity PresentationConnecting ApplicationsFTP, E-mail, Gopher

Web Pages Web Services

Page 9: Web Services Distributed Computing 9 Sep,2008 Shahid Mahmood

What is XML?What is XML?

XML is a “use everywhere” data specification

9

DocumentsConfiguration

Database

Application X

Repository

XML XML

XML XML

Page 10: Web Services Distributed Computing 9 Sep,2008 Shahid Mahmood

Web services infrastructure Web services infrastructure and componentsand components

Security

Service descriptions (in WSDL)

Applications

Directory service

Web Services

XML

Choreography

SOAP

URIs (URLs or URNs) HTTP, SMTP or other transport

Page 11: Web Services Distributed Computing 9 Sep,2008 Shahid Mahmood

Web Service StackWeb Service Stack

Page 12: Web Services Distributed Computing 9 Sep,2008 Shahid Mahmood

SOAP: Simple Object Access SOAP: Simple Object Access ProtocolProtocol

What is SOAP?◦ SOAP is a communication protocol ◦ SOAP is for communication between

applications ◦ SOAP is a format for sending messages ◦ SOAP is designed to communicate via Internet ◦ SOAP is platform independent ◦ SOAP is language independent ◦ SOAP is based on XML ◦ SOAP is simple and extensible ◦ SOAP will be developed as a W3C standard

Page 13: Web Services Distributed Computing 9 Sep,2008 Shahid Mahmood

SOAP: Simple Object Access SOAP: Simple Object Access ProtocolProtocol SOAP 1.0: Microsoft, Userland,

DevelopMentor Specific to COM and HTTP

SOAP 1.1: includes contributions from IBM and Lotus Substitutable transport binding (not just HTTP) Substitutable language binding (e.g. Java) Substitutable data encoding Completely vendor-neutral Independent of: programming language, object

model, operating system, or platform SOAP 1.2: current working draft from w3.org

“XML Protocol” working group

Page 14: Web Services Distributed Computing 9 Sep,2008 Shahid Mahmood

SOAP Message StructureSOAP Message Structure Request and Response messages

Request invokes a method on a

remote object Response returns result of running

the method SOAP specification defines an “envelop”

“envelop” wraps the message itself Message is a different vocabulary Namespace prefix is used to distinguish the two

parts

Application-specific message vocabulary

SOAP Envelop vocabulary

Page 15: Web Services Distributed Computing 9 Sep,2008 Shahid Mahmood

SOAP message in an SOAP message in an envelopeenvelope

envelope

header

body

header element

body element

header element

body element

Page 16: Web Services Distributed Computing 9 Sep,2008 Shahid Mahmood

SOAP SOAP Example of a simple request Example of a simple request without headerswithout headers

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

In this figure and the next, each XML element is represented by a shaded box with its name in italic followed by any attributes and its content

Page 17: Web Services Distributed Computing 9 Sep,2008 Shahid Mahmood

Example of a reply to the Example of a reply to the request request

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

Page 18: Web Services Distributed Computing 9 Sep,2008 Shahid Mahmood

HTTP POST Request in SOAP HTTP POST Request in SOAP client-server communicationclient-server communication

endpoint address

action

POST /examples/stringerHost: www.cdk4.netContent-Type: application/soap+xml

Action: 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>

So

ap

me

ssa

ge

HT

TP

hea

de

r

Page 19: Web Services Distributed Computing 9 Sep,2008 Shahid Mahmood

SOAP Request MessageSOAP Request Message

<?xml version="1.0"?><soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">

<soap:Body xmlns:m="http://www.stock.org/stock">

</soap:Body>

</soap:Envelope>

<m:GetStockPrice> <m:StockName>IBM</m:StockName> </m:GetStockPrice>

SOAP Envelope

Message

SOAP EnvelopeNamespace

MessageNamespace

Page 20: Web Services Distributed Computing 9 Sep,2008 Shahid Mahmood

SOAP Response MessageSOAP Response Message

<?xml version="1.0"?><soap:Envelopexmlns:soap="http://www.w3.org/2001/12/soap-envelope"soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"> <soap:Body xmlns:m="http://www.stock.org/stock">

</soap:Body></soap:Envelope>

<m:GetStockPriceResponse> <m:Price>34.5</m:Price></m:GetStockPriceResponse>

SOAP Envelope

Message

Result returned in

Body

Page 21: Web Services Distributed Computing 9 Sep,2008 Shahid Mahmood

Why SOAP?Why SOAP?Other distributed technologies failed on the

Internet◦ Unix RPC – requires binary-compatible Unix

implementations at each endpoint◦ CORBA – requires compatible ORBs◦ RMI – requires Java at each endpoint◦ DCOM – requires Windows at each endpoint

SOAP is the platform-neutral choice◦ Simply an XML wire format◦ Places no restrictions on the endpoint

implementation technology choices

Page 22: Web Services Distributed Computing 9 Sep,2008 Shahid Mahmood

SOAP Usage ModelsSOAP Usage ModelsRPC-like message exchange

◦ Request message bundles up method name and parameters

◦ Response message contains method return values

◦ However, it isn’t required by SOAPSOAP specification allows any kind of body

content◦ Can be XML documents of any type◦ Example:

Send a purchase order document to the inbox of B2B partner

Expect to receive shipping and exceptions report as response

Page 23: Web Services Distributed Computing 9 Sep,2008 Shahid Mahmood

Web Services Description Web Services Description LanguageLanguage

What is WSDL? WSDL is an XML document WSDL is used to describe Web services WSDL is also used to locate Web services WSDL is a W3C standard

Operational informationOperational information about the service Location of the service Service interface Implementation details for the service

interface

Page 24: Web Services Distributed Computing 9 Sep,2008 Shahid Mahmood

Web Services Description Web Services Description Language Language (WSDL)(WSDL)

is a format for describing a Web Services interface. It is a way to describe services and how they should be bound to specific network addresses. WSDL has three parts:◦Definitions ◦Operations ◦Service bindings

Page 25: Web Services Distributed Computing 9 Sep,2008 Shahid Mahmood

WSDL 2.0 Interface definition WSDL 2.0 Interface definition for Stock Quote Servicefor Stock Quote Service<?xml version="1.0"?> <definitions name="StockQuote“

targetNamespace="http://example.com/stockquote/definitions" xmlns:tns="http://example.com/stockquote/definitions" xmlns:xsd1="http://example.com/stockquote/schemas" xmlns:soap="http://www.w3.org/2003/11/wsdl/soap12" xmlns="http://www.w3.org/2003/11/wsdl"> <import namespace="http://example.com/stockquote/schemas" location="http://example.com/stockquote/stockquoteV20.xsd"/> <types> <schema targetNamespace="http://example.com/stockquote/definitions"> <element name="GetLastTradePriceInput" type="xsd1:TradePriceRequest"/> <element name="GetLastTradePriceOutput" type="xsd1:TradePrice"/> </schema> </types> <interface name="StockQuoteInterface"> <operation name="GetLastTradePrice" pattern="http://www.w3.org/2003/11/wsdl/in-out"> <input message="tns:GetLastTradePriceInput"/> <output message="tns:GetLastTradePriceOutput"/> </operation> </interface>

</definitions>

Page 26: Web Services Distributed Computing 9 Sep,2008 Shahid Mahmood

WSDL 2.0 Implementation definition for WSDL 2.0 Implementation definition for Stock Quote ServiceStock Quote Service<definitions name="StockQuote“

targetNamespace="http://example.com/stockquote/service" xmlns:tns="http://example.com/stockquote/service" xmlns:wsoap="http://www.w3.org/2003/11/wsdl/soap12" xmlns:defs="http://example.com/stockquote/definitions" xmlns="http://www.w3.org/2003/11/wsdl">

<import namespace="http://example.com/stockquote/definitions" location="http://example.com/stockquote/stockquoteV12.wsdl"/>

<binding name="StockQuoteSoapBinding" interface="defs:StockQuoteInterface"> <wsoap:binding protocol="http://www.w3.org/2003/11/wsdl/http"/>

<operation name="GetLastTradePrice">

<wsoap:operation soapAction="http://example.com/GetLastTradePrice"/>

<input> <wsoap:body/> </input>

<output> <wsoap:body/> </output>

</operation> </binding>

<service name="StockQuoteService">

<documentation>My stock quote service</documentation>

<endpoint name="StockQuoteEndPoint" binding="tns:StockQuoteSoapBinding"> <wsoap:address location="http://example.com/stockquote"/> </endpoint>

</service> </definitions>

Page 27: Web Services Distributed Computing 9 Sep,2008 Shahid Mahmood

WSDL – DEFINITIONWSDL – DEFINITIONAre generally expressed in XML, include both

data type definitions and message definitions that use the data type definitions.

These definitions are usually based upon some agreed upon XML vocabulary agreement. ◦ within an organization or between

organizations. ◦ industry-wide vocabulary.

If data type and message definitions need to be used between organizations, then most likely an industry-wide vocabulary will be used

BussinessXML, AccoutingXML, PhysicsXML, LegalXML, MathXML

http://www.service-architecture.com/xml/articles/xml_vocabularies.html

Page 28: Web Services Distributed Computing 9 Sep,2008 Shahid Mahmood

WSDL - OPERATIONWSDL - OPERATIONOperations describe actions for the

messages supported by a Web service. There are four types of operations:

One-way: One-way: Messages sent without a reply required

Request/response: Request/response: The sender sends a message and the received a reply.

Solicit response: Solicit response: A request for a response. (The specific definition for this action is pending.)

Notification: Notification: Messages sent to multiple receivers. (The specific definition for this action is pending.)

Page 29: Web Services Distributed Computing 9 Sep,2008 Shahid Mahmood

WSDL – SERIVCE BINDINGWSDL – SERIVCE BINDINGService bindings connect port types

to a port. A port is defined by associating a

network address with a port type. A collection of ports defines a service. This binding is commonly created

using SOAP, but other forms may be used. ◦These other forms could include

CORBA Internet Inter-ORB Protocol (IIOP), DCOM, .NET, Java Message Service (JMS), o WebSphere MQ to name a few.

Page 30: Web Services Distributed Computing 9 Sep,2008 Shahid Mahmood

Basic Parts of WSDLBasic Parts of WSDL

Page 31: Web Services Distributed Computing 9 Sep,2008 Shahid Mahmood

WSDL 2.0 Conceptual WSDL 2.0 Conceptual ModelModel

Page 32: Web Services Distributed Computing 9 Sep,2008 Shahid Mahmood

WSDL 2.0 SkeletonWSDL 2.0 Skeleton<definitions targetNamespace="xs:anyURI"> <documentation /> ? [<import /> | <include /> ] * <types /> ? [<interface /> | <binding /> | <service /> ] * </definitions>

Page 33: Web Services Distributed Computing 9 Sep,2008 Shahid Mahmood

WSDL 2.0 Skeleton - WSDL 2.0 Skeleton - DefinitionsDefinitionsDefinitions◦root element of any WSDL document. ◦serves as a container which holds all

the necessary information about the service and its attributes.

◦targetNamespace attribute of the definitions element is a required attribute of type anyURI. The namespace can directly or indirectly

define the semantics of the WSDL. Also, the definitions element can have other

optional attributes which correspond to various namespaces that may be used with in the WSDL document.

Page 34: Web Services Distributed Computing 9 Sep,2008 Shahid Mahmood

WSDL 2.0 Skeleton – Include WSDL 2.0 Skeleton – Include & Import& Import

Include element helps to modularize the web service descriptions. The location attribute is mandatory and specifies the

location of these WSDL documents. The actual value of the target namespace of the included

WSDL must match the target namespace of the definitions element in the including WSDL

Import The concept behind the import element is very similar to that of

include element, except that the imported WSDL can be in different target namespaces.

The namespace attribute for the import element is mandatory while the location attribute is optional.

Page 35: Web Services Distributed Computing 9 Sep,2008 Shahid Mahmood

WSDL 2.0 Skeleton – WSDL 2.0 Skeleton – TypesTypes Typeselement defines the data types used by

the exchanged messages. WSDL uses W3C XML Schema as its

preferred schema language. Schemas may be used by importing or

embedding within the types element of the WSDL document. Importing can be done using the construct

xs:import while embedding uses the construct xs:schema.

Page 36: Web Services Distributed Computing 9 Sep,2008 Shahid Mahmood

WSDL 2.0 Skeleton – WSDL 2.0 Skeleton – InterfaceInterface Interface element encloses a named set of abstract

operations and the abstract messages. can optionally extend one or more other

interfaces. interface operation element has name and

pattern as required attributes, while style is an optional attribute. Features defines functionalities associated with

the message exchanges between communicating parties, which might include reliability, security, correlation, and routing.

Property is used to control the behavior of a feature. It has a set of possible and permissible values specified by references to a schema description.

Page 37: Web Services Distributed Computing 9 Sep,2008 Shahid Mahmood

WSDL 2.0 Skeleton – WSDL 2.0 Skeleton – BindingBinding Binding element defines the underlying transport and

wire format for messages. Each binding in the WSDL references to an interface.

All operations defined within the interface must be bound in the binding.

An endpoint in the service component references a binding.

Both endpoints and bindings are modeled to support flexibility and location transparency.

Multiple endpoints with different network address can still share the same protocol binding.

WSDL 2.0 Bindings specification defines binding extensions for protocols and message formats such as SOAP, HTTP and MIME.

Page 38: Web Services Distributed Computing 9 Sep,2008 Shahid Mahmood

WSDL 2.0 Skeleton – WSDL 2.0 Skeleton – ServiceServiceService

◦element describes a set of endpoints which refer to a single network address for a binding.

◦All other protocol specific information is contained in the binding. Service can be referred by QName.

◦service element has a name and interface which are required attributes.

Page 39: Web Services Distributed Computing 9 Sep,2008 Shahid Mahmood

Universal Description, Universal Description, Discovery and Integration Discovery and Integration (UDDI) (UDDI) What is UDDI?

◦ Directory service where businesses can register and search for Web services Directory for storing information about web

services Directory of web service interfaces described

by WSDL ◦ UDDI communicates via SOAP

What is UDDI Based On? ◦ Uses W3C Internet standards such as XML,

HTTP, and DNS protocols◦ UDDI uses WSDL to describe interfaces to web

services

Page 40: Web Services Distributed Computing 9 Sep,2008 Shahid Mahmood

WSDL 2.0 Infoset, Schema WSDL 2.0 Infoset, Schema and Component Modeland Component Model

Page 41: Web Services Distributed Computing 9 Sep,2008 Shahid Mahmood

UDDI Roles and OperationsUDDI Roles and Operations Service Registry

Provides support for publishing and locating services

Like telephone yellow pages Service Provider

Provides e-business services

Publishes these services through a registry

Service requestor Finds required services via

the Service Broker Binds to services via

Service Provider

Page 42: Web Services Distributed Computing 9 Sep,2008 Shahid Mahmood

UDDIUDDIThe VisionThe Vision

Marketplace

Search Portal

Marketplace

Search Portal

Marketplace

Business Users

Advanced Discovery via Portals and Marketplaces

UDDI Registries and Protocol

Technical Users

Page 43: Web Services Distributed Computing 9 Sep,2008 Shahid Mahmood

How can UDDI be Used? How can UDDI be Used?

Page 44: Web Services Distributed Computing 9 Sep,2008 Shahid Mahmood

UDDI Benefits UDDI Benefits Making it possible to discover the right

business from the millions currently online

Defining how to enable commerce once the preferred business is discovered

Reaching new customers and increasing access to current customers

Expanding offerings and extending market reach

Page 45: Web Services Distributed Computing 9 Sep,2008 Shahid Mahmood

Thank UThank U

Page 46: Web Services Distributed Computing 9 Sep,2008 Shahid Mahmood

Lecture has prepared from Sir Atif Kamal slides with some modifications and enhancement