41
IBM Labs in Haifa J2EE Technologies: Web Services II Benny Rochwerger Research Staff Member

J2EE Technologies: Web Services II

  • Upload
    alexis

  • View
    41

  • Download
    2

Embed Size (px)

DESCRIPTION

J2EE Technologies: Web Services II. Benny Rochwerger Research Staff Member. Agenda. Web Services: What is it about XML Primer Simple Object Access Protocol – SOAP Describing Web Services – WSDL Discovering Web Services – UDDI Web Services in the Marketplace What is next - PowerPoint PPT Presentation

Citation preview

Page 1: J2EE Technologies: Web Services II

IBM Labs in Haifa

J2EE Technologies: Web Services II

Benny RochwergerResearch Staff Member

Page 2: J2EE Technologies: Web Services II

IBM Labs in Haifa

J2EE Technologies - Web Services II2 © 2003 IBM Corporation

Agenda

Web Services: What is it about

XML Primer

Simple Object Access Protocol – SOAP

Describing Web Services – WSDL

Discovering Web Services – UDDI

Web Services in the Marketplace

What is next

The Open Grid Services Architecture

Page 3: J2EE Technologies: Web Services II

IBM Labs in Haifa

J2EE Technologies - Web Services II3 © 2003 IBM Corporation

The Service Oriented Architecture (SOA)

ServiceProvider

ServiceProvider

ServiceRegistry

ServiceRegistry

ServiceRequestor

ServiceRequestor

Publish

Bind

Find

Page 4: J2EE Technologies: Web Services II

IBM Labs in Haifa

J2EE Technologies - Web Services II4 © 2003 IBM Corporation

The Web Services Stack

ServicePublication/Discovery

ServicePublication/Discovery

ServiceDescription

ServiceDescription

XML MessagingXML Messaging

Transport NetworkTransport Network

UDDI

WSDL

SOAP

HTTP, SMTP, MQSeries, etc.

Page 5: J2EE Technologies: Web Services II

IBM Labs in Haifa

J2EE Technologies - Web Services II5 © 2003 IBM Corporation

Web Services Description Language (WSDL)

Why service descriptions are needed ?

SOAP is the format of the envelope

It does not specify what message goes into the envelope

A formal mechanism to describe

What goes into the body

What messaging protocol to use

What address to send the message to

Page 6: J2EE Technologies: Web Services II

IBM Labs in Haifa

J2EE Technologies - Web Services II6 © 2003 IBM Corporation

Web Services Description Language (WSDL)

Application level service description (abstract interface)

What a service does

Operations, parameters, return values

Protocol-specific details needed to access the service end points

(concrete binding information)

How a service is accessed

Data formats and protocols necessary

Where a service is located

Network address of service provider

Page 7: J2EE Technologies: Web Services II

IBM Labs in Haifa

J2EE Technologies - Web Services II7 © 2003 IBM Corporation

WSDL Elements

WHAT

portType An abstract interface definition

Consist of operation elements

Abstract method signature

message Set of parameters referred to by method signatures

It is decomposed into part elements

type The collection of all the data types used in the Web Service

Page 8: J2EE Technologies: Web Services II

IBM Labs in Haifa

J2EE Technologies - Web Services II8 © 2003 IBM Corporation

WSDL Elements (cont.)

HOW

binding Details of how elements in abstract interface are to be converted into a

concrete representation

Data formats

Network protocols

WHERE

port How a binding is deployed at a particular network endpoint

service A named collection of ports

Page 9: J2EE Technologies: Web Services II

IBM Labs in Haifa

J2EE Technologies - Web Services II9 © 2003 IBM Corporation

The portType Element

<portType name="StockAvailableNotificationPortType"> <operation name="registration">

. . . </operation>

<operation name="notification"> . . .

</operation>

<operation name="expirationNotification"> . . .

</operation>

<operation name="cancellation"> . . .

</operation></portType>

Page 10: J2EE Technologies: Web Services II

IBM Labs in Haifa

J2EE Technologies - Web Services II10 © 2003 IBM Corporation

The operation Element

Request-response style of operation input, output and zero or more faults Most common style Maps nicely to HTTP

<!--Registration Operation --><operation name="registration"> <input message="StockAvailableRegistrationRequest"/> <output message="StockAvailableRegistrationResponse"/> <fault message="StockAvailableRegistrationError" name="StockAvailableNotificationErrorMessage"/> <fault message="StockAvailableExpirationError" name="StockAvailableExpirationError"/></operation>

Page 11: J2EE Technologies: Web Services II

IBM Labs in Haifa

J2EE Technologies - Web Services II11 © 2003 IBM Corporation

The operation Element (cont.)

One-way style of operation input message only Useful to change state of service provider HTTP response is an acknolegment of the message with no

application level semantics

<!--Cancellation Operation --><operation name="cancellation"> <input message=" StockAvailableCancellation"/></operation>

Page 12: J2EE Technologies: Web Services II

IBM Labs in Haifa

J2EE Technologies - Web Services II12 © 2003 IBM Corporation

The operation Element (cont.)

Notification style of operation output message only Asynchronous one-way push from service provider Useful for notifying state information back to requestor

<!--Expiration Notification Operation --><operation name="expirationNotification"> <output message="StockAvailableExpirationNotification"/></operation>

Page 13: J2EE Technologies: Web Services II

IBM Labs in Haifa

J2EE Technologies - Web Services II13 © 2003 IBM Corporation

The operation Element (cont.)

Solicit-response style of operation output, input and zero or more faults Initiated by service provider as in the notification style Response is expected from service requestor

<!— Solicit Requestor ID Operation --><operation name=“getRequestorID"> <output message=“getRequestorIDSolicit"/> <input message=“getRequestorIDSolicitResponse"/> <fault name=“RequestorIDNotAvailableError”

message=“RequestorIDNotAvailableErrorMessage”></operation>

Page 14: J2EE Technologies: Web Services II

IBM Labs in Haifa

J2EE Technologies - Web Services II14 © 2003 IBM Corporation

The message and part Elements

A message A named collection of parts Can be used as input, output or fault within an operation

A part A <name, type> tuple

<Message Name="Stockavailableregistrationerror"> <Part Name="Errorstring" Type="Xsd:String"/></Message><Message Name="Stockavailableregistrationresponse"> <Part Name="Correlationid" Type="Reg:Correlationid"/></Message><Message Name="Stockavailableregistrationrequest"> <Part Name="Registration" Element="Reg:Registrationrequest"/> <Part Name="Expiration" Type="Xsd:Timeinstant"/></Message>

Use simple types directly or complex types defined in the types element

Types are a complexType or an element

Page 15: J2EE Technologies: Web Services II

IBM Labs in Haifa

J2EE Technologies - Web Services II15 © 2003 IBM Corporation

From Java to WSDL …

<wsdl:message name="SymbolRequest"> <wsdl:part name="symbol" type="xsd:string"/></wsdl:message>

<wsdl:message name="QuoteResponse"> <wsdl:part name="quote" type="xsd:float"/></wsdl:message>

<wsdl:portType name="StockQuoteService"> <wsdl:operation name="getQuote"> <wsdl:input message="tns:SymbolRequest"/> <wsdl:output message="tns:QuoteResponse"/> </wsdl:operation></wsdl:portType>

public class StockQuoteService { public float getQuote (String symbol) throws Exception { return com.ibm.wstk.util.Quote.getQuote( symbol ); }}

Page 16: J2EE Technologies: Web Services II

IBM Labs in Haifa

J2EE Technologies - Web Services II16 © 2003 IBM Corporation

The binding Element

How to format messages How WSDL relates to SOAP headers, bodies, encoding, etc. The binding element tells service requestor how to format messages in a

protocol-specific manner Each portType can have more than one binding associated

Page 17: J2EE Technologies: Web Services II

IBM Labs in Haifa

J2EE Technologies - Web Services II18 © 2003 IBM Corporation

<binding name="StockAvailableNotificationSOAPBinding" type="StockAvailableNotificationPortType"> <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>

<operation name="registration"> <soap:operation soapAction= http://www.skatesTown.com/StockAvailableNotification/registration/>

<input> <soap:header message="StockAvailableRegistrationRequest" part="expiration" use="encoded“ namespace="http://www.skatestown.com/ns/registrationRequest“ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> <soap:body parts="registration" use="literal" style="document"/> </input>

Unique name

The binding Element

The type attribute is used to identify portType

Use SOAP messaging

RPC or document

SOAP/HTTP

Set the soapAction HTTP header.Can be used as a routing hint

Put the “expiration” part of the message into the SOAP headerEncode data, i.e., serialize/deserializePut the “registration” part of the message into the SOAP bodyDo not encode data, i.e., pass XML to/from application

Page 18: J2EE Technologies: Web Services II

IBM Labs in Haifa

J2EE Technologies - Web Services II19 © 2003 IBM Corporation

The binding Element (cont.)

<output> <soap:body use="encoded" namespace="http://www.skatestown.com/ns/registrationRequest" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> </output> <fault name="StockAvailableNotificationErrorMessage"> <soap:fault name="StockAvailableNotificationErrorMessage" namespace="http://www.skatestown.com/ns/registrationRequest" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> </fault> </operation></binding>

Page 19: J2EE Technologies: Web Services II

IBM Labs in Haifa

J2EE Technologies - Web Services II20 © 2003 IBM Corporation

The service and port Elements

service Container of port elements

port Identify network address of endpoint

<service name="StockAvailableNotificationService"> <port name="StockAvailableNotificationPort“ binding="StockAvailableNotificationSOAPBinding"> <soap:address location="http://www.xyz.com/axis/services/StockNotification"/> </port></service>

Page 20: J2EE Technologies: Web Services II

IBM Labs in Haifa

J2EE Technologies - Web Services II21 © 2003 IBM Corporation

Using WSDL

Service client development

Input to proxy generator which produces client code

Service invocation

Input to dynamic invocation proxy which generates, at run time,

correct service requests

Page 21: J2EE Technologies: Web Services II

IBM Labs in Haifa

J2EE Technologies - Web Services II22 © 2003 IBM Corporation

ApplicationApplication

SOAP EngineSOAP Engine

Network ProtocolNetwork Protocol

Service Requestor

Service Invocation

Web ServiceWeb Service

SOAP EngineSOAP Engine

Network ProtocolNetwork Protocol

Service Provider Y

Web ServiceWeb Service

SOAP EngineSOAP Engine

SMTPSMTP

Service Provider X

HTTPHTTP HTTPHTTP

Page 22: J2EE Technologies: Web Services II

IBM Labs in Haifa

J2EE Technologies - Web Services II23 © 2003 IBM Corporation

ApplicationApplication

SOAP EngineSOAP Engine

Network ProtocolNetwork Protocol

Service Requestor

Service Invocation

Web ServiceWeb Service

SOAP EngineSOAP Engine

HTTPHTTP

Service Provider Y

Web ServiceWeb Service

SOAP EngineSOAP Engine

SMTPSMTP

Service Provider X

SMTPSMTP

Page 23: J2EE Technologies: Web Services II

IBM Labs in Haifa

J2EE Technologies - Web Services II24 © 2003 IBM Corporation

WSDL Summary

Elements to define abstract interface of a service

What a service does

Elements to specify concrete binding information

How a service is accessed

Where a service is located

Page 24: J2EE Technologies: Web Services II

IBM Labs in Haifa

J2EE Technologies - Web Services II25 © 2003 IBM Corporation

UDDI – Universal Description, Discovery and Integration

XML-based mechanism to build centralized registry of services Facilitate service discovery both at design time and dynamically at

runtime UDDI is a:

Business Registry Public online business/services registry Available since 2001 Consists of replicas hosted at UDDI Operators

Currently there are two: IBM and Microsoft Operators should be indistinguishable

Set of APIs and data structures Enable programmatically registration and inquiry of services

Page 25: J2EE Technologies: Web Services II

IBM Labs in Haifa

J2EE Technologies - Web Services II26 © 2003 IBM Corporation

The UDDI Data Structures

The businessEntity data structure White pages

Name, address and contact information Yellow pages

Classification information about the types and location of the services the entity offers

Green pages Technical data, e.g., how to invoke the offered services

The tModel data structure An abstract technology model that is used to represent the reusable

definition of a service (the interface)

The bindingTemplate data structure Holds the technical information for the service to actually be invoked

Page 26: J2EE Technologies: Web Services II

IBM Labs in Haifa

J2EE Technologies - Web Services II27 © 2003 IBM Corporation

The UDDI APIs

A set of Create, Read, Update and Delete (CRUD) operations

Business Service Binding tModel

Save/Update save_business save_service save_binding save_tModel

Delete delete_business delete_service delete_binding delete_tModel

Find find_business find_service find_binding find_tModel

GetDetail get_businessDetail get_serviceDetail get_bindingDetail get_tModelDetail

Page 27: J2EE Technologies: Web Services II

IBM Labs in Haifa

J2EE Technologies - Web Services II28 © 2003 IBM Corporation

UDDI Pointers

The UDDI initiative

http://www.uddi.org

IBM

http://www.ibm.com/services/uddi

Microsoft

http://uddi.microsoft.com

Page 28: J2EE Technologies: Web Services II

IBM Labs in Haifa

J2EE Technologies - Web Services II29 © 2003 IBM Corporation

The Web Services Landscape (partial)

The J2EE world

BEA – WebLogic Server http://www.bea.com/products/weblogic/server

Iona – XMLBus http://www.xmlbus.com/

Macromedia – JRun http://www.macromedia.com/software/jrun

Sun – Sun ONE Application Server http://wwws.sun.com/software/products/appsrvr/home_appsrvr.html

IBM – WebSphere http://www.ibm.com/websphere

Page 29: J2EE Technologies: Web Services II

IBM Labs in Haifa

J2EE Technologies - Web Services II30 © 2003 IBM Corporation

The Web Services Landscape (partial)

.NET

Microsoft’s platform for distributed computing

Common Language Runtime (CLR)

Similar to Java’s virtual machine

bytecode generated from C#, C++, Visual Basic, COBOL

Core classes

Similar to Java class library

ASP.NET

A programming framework built on CLR that can be used on a server

to build Web applications

Equivalent to J2EE container ?

Page 30: J2EE Technologies: Web Services II

IBM Labs in Haifa

J2EE Technologies - Web Services II31 © 2003 IBM Corporation

The Web Services Landscape (partial)

Other languages and environments SOAP::Lite

Perl interface to the SOAP. Both client and server http://www.soaplite.com/

SOAPPy Python interface to the SOAP. Both client and server http://sourceforge.net/projects/pywebsvcs

eSOAP A C++ library that provides a SOAP engine for embeddeding systems Available on

RTEMS, eCos, QNX Microsoft Windows - NT/2000/98/ME Linux

http://www.embedding.net/eSOAP

Page 31: J2EE Technologies: Web Services II

IBM Labs in Haifa

J2EE Technologies - Web Services II32 © 2003 IBM Corporation

The Apache eXtensible Interaction System (AXIS)

A very flexible SOAP engine from Apache

Open and pluggable architecture

Design to cope with various deployment configuration

From very simplistic to highly sophisticated configurations

The Java Web Services facility (JWS)

Drop-in development

Simplest and quickest way to deploy a Java-base Web Service

Rename source file from xxx.java to xxx.jws

Drop xxx.jws into JWS directory

Page 32: J2EE Technologies: Web Services II

IBM Labs in Haifa

J2EE Technologies - Web Services II33 © 2003 IBM Corporation

Axis Components

Axis Engine Main entry point into message processing model Coordinate message flow

Handlers Message processing logic

Chains Ordered collections of handlers (invoked sequentially) Pre/post processing of messages is achieved by defining chains

Dispatcher (the pivot handler) The bridge between Axis and the business logic (i.e., the Web Service) The RPCDispatcher

SOAP body to/from Java objects Location and Invocation of code

Page 33: J2EE Technologies: Web Services II

IBM Labs in Haifa

J2EE Technologies - Web Services II34 © 2003 IBM Corporation

Axis Components (cont.)

Transport Listeners Deal protocol specific encapsulation Responsible for Axis Engine instantiation The AxisServlet

A transport listener for HTTP

Deployment/Configuration Add/remove Web Services to Axis Creation of service specific chains Configuration of transport and global chains

Serializers/Deserializers Convertion of native data types to/from XML

Page 34: J2EE Technologies: Web Services II

IBM Labs in Haifa

J2EE Technologies - Web Services II35 © 2003 IBM Corporation

Request Handlers

Response Handlers

Axis on the Server

DispatcherDispatcherAxisEngine

AxisEngine

TransportRequest

Chain

GlobalRequest

Chain

TransportResponse

Chain

GlobalResponse

Chain

TLTransportRequestorRequestor

TLTransportRequestorRequestor

WebService

WebService

Web Service specific chain

Page 35: J2EE Technologies: Web Services II

IBM Labs in Haifa

J2EE Technologies - Web Services II36 © 2003 IBM Corporation

Axis on the Client

TransportApplicationApplication TransportSender

TransportSender

AxisEngine

AxisEngine

TransportRequest

Chain

GlobalRequest

Chain

TransportResponse

Chain

GlobalResponse

Chain

Web Servicespecific request

handlers

Web Servicespecific response

handlers

Page 36: J2EE Technologies: Web Services II

IBM Labs in Haifa

J2EE Technologies - Web Services II37 © 2003 IBM Corporation

What is missing in the Web Services Model ?

getQuote(“BMW”)

Stock Quotes Provider

BMW (ISE:BMW)      Time: 7:11 Last Price:   1961.00    Change:    +18.00   Open:    1942.00  High:    1977.00 @ 5:41 ET Low:    1927.00 @ 3:16 ET Currency:  GBX 

Used Motorcycle dealer

1. BMW K 1200 RS Mileage: 8266 Year: 1999 Price: £6950

2. BMW R 1100 S   Mileage:10347Year: 1998 Price: £5750

3. BMW R 1100 S  Mileage : 7284Year: 1999 Price: £6250

4. BMW R 1100 S  Mileage: 9000Year: 2000 Price: £6350

Page 37: J2EE Technologies: Web Services II

IBM Labs in Haifa

J2EE Technologies - Web Services II38 © 2003 IBM Corporation

What is missing in the Web Services Model ?

Service description captures interface syntax

The service accepts an operation request with a particular signature

Service description does not capture semantics

The Open Grid Services Architecture

Operation should respond as expected

“As expected” is usually defined offline in specifications

Use names as basis for reasoning about semantics

Standardize common services and operations

Page 38: J2EE Technologies: Web Services II

IBM Labs in Haifa

J2EE Technologies - Web Services II39 © 2003 IBM Corporation

What is Next – The Open Grid Services Architecture

Standard interfaces and behaviors that address key distributed system issues: Service description & information access Notification Policy management Lifetime management Service naming Authentication Reliable invocation

Transient stateful service instances

Page 39: J2EE Technologies: Web Services II

IBM Labs in Haifa

J2EE Technologies - Web Services II40 © 2003 IBM Corporation

The OGSA Framework

Page 40: J2EE Technologies: Web Services II

IBM Labs in Haifa

J2EE Technologies - Web Services II42 © 2003 IBM Corporation

Tools and Information

Suggested reading Building Web Services with Java by Graham et.al., 2002, Sams Publishing AXIS, Next Generation Java SOAP by Irani ant Basha, 2002, Wrox Press

Web Services Standards http://www.w3.org/2002/ws/

Apache’s AXIS http://xml.apache.org/axis/

IBM developerWorks : Web Services http://www.ibm.com/developerworks/webservices

IBM developerWorks : WebSphere http://www7b.software.ibm.com/wsdd/

Other Web Services good sites www.webservices.org www.gotdotnet.com

The OGSA Working Group http://www.gridforum.org/ogsa-wg/

Page 41: J2EE Technologies: Web Services II

IBM Labs in Haifa

J2EE Technologies: Web Services II

Benny RochwergerResearch Staff Member