Web services (WS) Outline. Intro on Middleware SOAP, HTTP binding WSDL UDDI Development tools References

31  Download (0)

Full text

(1)

Web services (WS)

Outline

ƒ Intro on Middleware ƒ SOAP, HTTP binding ƒ WSDL ƒ UDDI ƒ Development tools ƒ References

(2)

3

Programming Trends

ƒ

Programming languages and

software system evolve towards:

Šhigher levels of abstraction hiding hardware and platform details

Šmore powerful primitives and interfaces

Šreducing the development and

maintenance cost of the applications developed by facilitating their

portability (e.g. Java)

Middleware as abstraction

ƒ Middleware is mainly a set of programming abstractions:

Šdeveloped to facilitate the

development of complex distributed systems

Što understand a middleware platform one needs to understand its

programming model

ƒ Programming abstraction gets higher Šunderlying middleware infrastructure

(3)

5

Middleware layers

Middleware for program abstraction

ƒ Web Services apply existing abstractions

to Internet

ƒ SOAP like RPC, wrapped in XML, and

mapped to HTTP to transport on Internet

ƒ Evolution and appearance to the

programmer is dictated by the trends in programming language

ŠRPC and C,

ŠCORBA and C++, ŠRMI and Java, ŠWeb services

(4)

7

Middleware for integration

ƒ Provide a full platform for developing and running complex distributed

systems

ƒ Trend is towards Service Oriented

Architectures and standardization of interfaces

ƒ Evolution is towards integration of platforms and flexible configuration

Distributed architectures

ƒ Need for communicating across the net ƒ IIOP (Internet Inter-ORB Protocol) as

CORBA/OMG standard protocol

ƒ DCOM (Distribuited COM) as MS Windows standard

ƒ RMI (Remote Method Invocation) as Java standard

(5)

9

Evolution

TCP/IP HTML + JSP XML + SOAP Technology

Functionality Connectivity presentationDynamic Integration

Innovation FTP, E-Mail, HTTP Web pages Web services

Browsing the Web

Programming the Web

Evolution of Distributed Arch.

COM CORBA DCOM IIOP RMI RPC JMS MSMQ XML RPC SOAP Component-Based Architectures Component-Based Distributed

Architectures Web Services binary/text async Vendor Platform Language sync J2EE

(6)

11

Problems

ƒ Distributed protocols are very complex

ƒ Communicating peers must share the

same object model

ƒ Firewall are critical points ƒ Protocols are too different

Definition of Web Service

Web services are modular applications that are self-describing and that can be published, located, and invoked

from anywhere on the web or within

any local network based on open Internet standars

(7)

13

Definition of Web Service (2)

ƒ Component that can invoked via the

Internet by means of XML-based messages

ƒ Can be made of (or used by) other web services

ƒ Objectives

Š Transparent with regard to h/w platforms, operating systems, programming languages, and proprietary standards

Š Integration and collaboration among heterogeneous systems

Web Services: benefits

ƒ Transparency

ƒ Simplicity (!?)

ƒ Reuse of an existing infrastructure (web)

ƒ Loose coupling between components

(8)

15

Element of WSs

ƒ Discovery: where is the service? ƒ Description: what does the service?

ƒ Invocation/Transport Invocation Description Discovery Transport

Elements of WSs (2)

ƒ XML: standard for data representation

ƒ SOAP: communication protocol

ƒ WSDL: language describing the WS

ƒ UDDI: registry for discovery

SOAP/XML/XSD WSDL UDDI HTTP HTTPS TCP/IP

(9)

17

Scenario

Find (UDD I) Pub lish (U DD I) WSDL Bind (SOAP + XML) Service Requester UDDI Registry Service Provider WSDL WSDL

The Web service cycle

Service Provider WSDL 1. Service Provider Creates Capability, and Registers interface Service Registry 2. Potential consumer searches registry for a suitable service Service Consumer UDDI 3. Consumer finds service and downloads interface WSDL 4. Consumer composes request based on WSDL & packages it in SOAP envelope SOAP 5. Provider parses request and performs service 6. Reply is marshaled into another WSDL, and stuffed in a SOAP envelope SOAP 7. Consumer consumes message

(10)

19

Web Services Standard Bodies

ƒ Main standard bodies relevant to Web

services:

ƒ W3C (World Wide Web Consortium)

ƒ OASIS (Organization for the

Advancement of Structured Information Standard

ƒ WS-I (Web Services Interoperability Organization)

(11)

21

WS standards & specifications

(12)

23

SOAP

ƒ Simple Object Access Protocol

ƒ Simple and extensible communication

protocol based on Internet standard ŠXML for message format

ŠHTTP for transport (SOAP bindings)

ƒ A SOAP message is an XML document

describing a processing request or a result

Structure of a SOAP message

ƒ Envelope: message

container element

ƒ Header: (optional)

contains extensions ƒ Body: payload (e.g.

request or response)

ƒ Fault: (optional) informazion about errors (inside body)

Envelope Header

Body

Header Entry Header Entry

(13)

25

Example

<SOAP-ENV:Envelope xmlns:SOAP-ENV = "http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC = "http://schemas.xmlsoap.org/soap/encoding"> <SOAP-ENV:Header>...</SOAP-ENV:Header> <SOAP-ENV:Body> <SOAP-ENV:Fault></SOAP-ENV:Fault> </SOAP-ENV:Body> </SOAP-ENV:Envelope>

Use of Header

<soap:Envelope> <soap:Header>

<!-- If extension is not understood

-- reject message and return error -->

<t:Transaction xmlns="TSchemaURI" mustUnderstand="1"> <!-- Part of transaction no. 5 --> 5

</t:Transaction>

</soap:Header>

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

(14)

27

SOAP RPC

ƒ IDL definition of remote method

Š double GetStockQuote

(in string symbol);

ƒ How to invoke the servant with SOAP

messages?

SOAP RPC request

Invoked method Arguments <SOAP-ENV:Envelope xmlns:SOAP-ENV="..."> <SOAP-ENV:Header/> <SOAP-ENV:Body> <m:GetStockQuote xmlns:m="http://acme.it/ns/nyse"> <m:symbol>SUNW<m:symbol>

</m:GetStockQuote> </SOAP-ENV:Body>

(15)

29

SOAP RPC response

<SOAP-ENV:Envelope xmlns:SOAP-ENV="..."> <SOAP-ENV:Header/> <SOAP-ENV:Body> <m:GetStockQuoteResponse xmlns:m="..."> <m:ret xsi:type="xsd:string"> 30.5 </m:ret> </m:GetStockQuoteResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope> Return Response

HTTP primer

ƒ Request/response protocol ƒ Stateless ƒ Tex-based protocol

ƒ Single transaction per connection (1.0)

Š Multiple transactions (1.1)

ƒ Transfer of textual content

Š Multimedia content with MIME (MIME header prepended as decodification hint)

– MIME-Version, Content-Type, Content-Transfer-Encoding

(16)

31

HTTP request messages

ƒ GET

ŠRequests the specified document. The document is returned as text appended to the response

ƒ POST

ŠRequests to send the appended text to the specified document for processing

ƒ Command, Header, Data

HTTP POST request

POST /cgi-bin/example HTTP/1.1 Content-type: text/plain

Content-Length: 15 String to count

(17)

33

HTTP response message

ƒ Return code (explanation), header, data

ƒ Codici

Š1xx Informational (received, still working) Š2xx Success

Š3xx Redirection

Š4xx Client error (bad request format) Š5xx Server error (request OK, can't fulfill)

HTTP response message

ƒ Successful response Š HTTP/1.1 200 OK Content-type: text/plain Content-Length: 2 15 ƒ Redirect Š HTTP/1.1 301 Moved Permanently Location: http://somewhere Content-Length: 0

(18)

35

HTTP extension headers

ƒ 46 pre-defined headers

ƒ New headers can be defined

ƒ Ignored if not understood

HTTP binding

ƒ POST method must be used

ƒ Content type must be text/xml

ƒ Return code for errors must be 500

(Internal Server Error)

ƒ SOAP extension header must be

present

Š SOAPAction: "Some-URI" ŠURI to be executed

(19)

37

Example (Stock Quotes - req)

POST /market HTTP/1.1 Content-Type: text/xml Content-Length: ### SOAPAction: "http://acme.it/market" <SOAP-ENV:Envelope> <SOAP-ENV:Header/> <SOAP-ENV:Body> <m:GetStockQuote> <m:symbol>SUNW<m:symbol> </m:GetStockQuote> </SOAP-ENV:Body> </SOAP-ENV:Envelope>

Example (Stock Quotes - ret)

HTTP/1.1 200 OK Content-Type: text/xml Content-Length: ### <SOAP-ENV:Envelope> <SOAP-ENV:Header/> <SOAP-ENV:Body> <m:GetStockQuoteResponse> <m:ret>30.5</m:ret> </m:GetStockQuoteResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope>

(20)

UDDI

UDDI

ƒ Universal Description, Discovery and

Integration

ƒ It specifies interfaces and behaviour of a Service Registry

ƒ Organize Information per category

(Taxonomy) and types of services offered

(21)

41

Struttura

ƒ Many Industries (UDDI Operators) host

a "UDDI Global Registry"

ƒ Similar to DNS (with replication on ech node) UDDI.org UDDI.org UDDI Node UDDI Node UDDI Node UDDI Node UDDI Node UDDI Node UDDI Node UDDI Node

Informazioni di UDDI

ƒ White pages: informazioni sui contatti dell'azienda fornitrice del servizio

ƒ Yellow pages: informazioni relative alla categoria di appartenenza dell'azienda ƒ Green pages: informazioni tecniche

relative al web service fornito dall'azienda

(22)

43

Scenario

1. Standard bodies populate the UDDI with description of various kinds of services 2. Service providers load descriptions of their

exported service instances (together with company info, contact info, etc.)

3. Each service is assigned with a globally unique ID

4. Client retrieves location and description 5. Client invokes the service

(23)

45

WSDL

ƒ Web Services Description Language ƒ Consente di definire l’niterfaccia dei

servizi utilizzando un documento XML

ƒ Un documento WSDL fornisce tutte le

informazioni necessarie per l'utilizzo di un servizio web

Šlocalizzazione,

Šformato dei messaggi, Šprotocollo di trasporto

Esempio

ƒ Descrizione di un servizio che fornisce le temperature correnti delle capitali del mondo

ƒ Il servizio fornisce un'unica operazione chiamata

float GetCurrentTemp(in string city); e può essere utilizzata attraverso protocollo SOAP via HTTP

(24)

47

Esempio

<SOAP-ENV:Envelope> <SOAP-ENV:Header/> <SOAP-ENV:Body> <ct:GetCurrentTemp> <ct:City>Turin</ct:City> </ct:GetCurrentTemp> </SOAP-ENV:Body> </SOAP-ENV:Envelope> <SOAP-ENV:Envelope> <SOAP-ENV:Header/> <SOAP-ENV:Body> <ct:CurrentTempReply> <ct:Temp>25.0</ct:Temp> </ct:CurrentTemp> </SOAP-ENV:Body> </SOAP-ENV:Envelope> request response

WSDL file structure

<?xml version="1.0"?> <definitions> <documentation></documentation> <types></types> <message></message> <message></message> <portType></portType> <binding></binding> <service></service> </definitions>

(25)

49

Definition of a WSDL interface

<?xml version="1.0"?>

<definitions name="CurrentTemp"

targetNamespace="http://example.com/ct.wsdl" xmlns:tns="http://example.com/ct.wsdl" xmlns:ct="http://example.com/ct.xsd" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap" xmlns="http://schemas.xmlsoap.org/wsdl"> <documentation>

Temperatures of capital cities </documentation> </definitions> <types> <schema targetNamespace="http://example.com/ct.xsd" xmlns="http://www.w3.org/2000/10/XMLSchema"> <element name="CurrentTempReq">

<complexType>

<element name="City" type="sting"> </complexType>

</element>

<element name="CurrentTempReply"> <complexType>

<element name=“Temp" type="float"> </complexType>

</element> </schema> </types>

(26)

51

Messages

ƒ Types can be used to compose

messages format used by the Web Service <message name="GetCurrentTempInput"> <part name="body" element="ct:CurrentTempReq"/> </message> <message name="GetCurrentTempOutput"> <part name="body" element="ct:CurrentTempReply"/> </message>

Operations

ƒ Define how to use messages to

execute an operation

<portType name="CurrentTempPortType"> <operation>

<input message="tns:GetCurrentTempInput"/> <output message="tns:GetCurrentTempOutput"/> </operation>

(27)

53

Binding

ƒ Modalita' di accesso ad una operazione

esportata ŠBinding

ŠSchema di comunicazione

<binding name="CurrentTempBind"

type="tns:CurrentTempPortType">

<soap:binding style="rpc" transport="http"/> <operation name="GetCurrentTemp">

<soap:operation soapAction="http://example.com/GetCurrentTemp"/> <input> <soap:body use="literal"/> </input> <output> <soap:body use="literal"/> </output> </operation> </wsdl:binding>

(28)

55

Communication Schema

ƒ One-way Š <operation><input/></operation> ƒ Request/Response Š <operation><input/><output/></operation> ƒ Solicit/Response Š <operation><output/><input/></operation> ƒ Notification Š <operation><output/></operation>

Service specification

ƒ Service specification

Š Which operations are provided (port) Š Which binding style

Š Where (URI) <service name="CurrentTempService"> <port name="CurrentTempPort" binding="tns:CurrentTempBind"> <soap:address location="http://example.com/currenttemp"/> </port> </service>

(29)

Web Services Development

Toolkits

ƒ SUN WSDP

ŠWeb Services Developers Pack

ƒ Apache AXIS (open source)

– Provides server-side infrastructure for deploying SOAP services on Java Web Container

– Provides client-side API for invoking SOAP services

– HTTP, SMTP

ŠXerces: XML parsers in Java, C++

(30)

59

Toolkits

ƒ Microsoft SOAP toolkit

Š Provides the infrastructure suitable for building, publishing, exploiting a web service using the Visual Studio 6.0 environment

Š Provides a SOAP listener (HTTP)

Š Provides wizards to convert already existing COM components to web services

Š Provides wizards to extract the WSDL

description starting from the COM/DCOM code

Development platforms

ƒ SUN | ONE (Sun Microsystem)

ƒ Visual Studio .NET (Microsoft) ƒ Eclipse Plug-ins

(31)

61

References

ƒ W3C docs ŠXML, www.w3.org/TR/REC-xml/ ŠNS, www.w3.org/TR/REC-xml-names/ ŠSchema, www.w3.org/TR/xmlschema-0/ ŠSOAP, www.w3.org/TR/SOAP/ ŠWSDL, www.w3.org/TR/wsdl/

References

ƒ UDDI Šwww.uddi.org/specification.html ƒ Java Web Services Tutorial

Šjava.sun.com/webservices/

ƒ Microsoft MSDN Library

Figure

Updating...

References