Web Services

  • Uploaded by: Uday Kumar
  • 0
  • 0
  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Web Services as PDF for free.

More details

  • Words: 1,215
  • Pages: 21
Web Services and J2EE

Dan Harkey

Agenda

9Introduction to Web Services 9Web Services and EJB

1

Introduction

9Next step in distributed computing evolution 9Web Services are ƒ self-describing ƒ lightweight ƒ inter-galactic components

Evolution

9Remote Procedure Calls (RPCs) 9Distributed Component Architectures ƒ CORBA, DCOM ƒ RMI & EJB

9XML-RPC, SOAP 9Web Services

2

Web Services and Distributed Objects …

9 Both attempt to provide distributed computing solutions over a network ƒ Software components executing in different processes on different systems 9 Both provide mechanisms for locating components ƒ Naming or directory service of some type ƒ Web services model provides a service registry 9 Both provide encoding methods or function invocations between participants

Web Services and Distributed Objects … (cont.)

9 Provide mechanisms for suitably marshalling parameters passed as arguments in function calls or method invocations 9 Provide rules detailing on-the-wire bits and bytes 9 Provide mechanisms for determining if faults have occurred during a method call or function invocation 9 Provide introspection capabilities

3

What Web Services aren’t…

9Web services are not object oriented

ƒ No object reference ƒ No encapsulated data ƒ Data has to be always passed or pointed to ƒ No Polymorphism

What is a Web Service

9Set of endpoints operating on XML messages 9Endpoint is defined by set of ƒ Operations ƒ Messages (arguments, results)

4

Web Services Roles

9 Service provider publishes information about the service to a service registry.

9 Service registry maintains a catalog of deployed

(published) services and makes this catalog available to new service providers and service requestors 9 Service Requester finds the service by using a lookup against the service registry, and then binds to the service provider. The provider and requestor can then interact

Web Services Roles

5

Web Service Provider Tasks

9Create or obtain WSDL document describing

web service 9Implement service 9Deploy service 9Publish WSDL defining concrete service ƒ Includes binding and addressing information for service endpoints

Web Services Requester Tasks

9Obtain WSDL description of service 9Create artifacts to use service 9Send messages to endpoints/receive responses

6

Web Service Invocation

Web Services Architecture

7

Web Services Building Blocks BPEL BPML

Basic Building Blocks 9 Simple Object Access Protocol (SOAP)

ƒ XML based messaging framework • Application-to-application protocol. • Provides serialization formats and RPC-style mapping

9 Universal Description, Discovery and Integration (UDDI)

ƒ A repository for discovering and registering Web Service descriptions

9 Web Services Definition Language (WSDL)

ƒ XML application designed to describe all information needed to interact with a service • messages, operations and protocol mappings

8

Building Blocks

9 Transport protocols

ƒ HTTP, FTP, SMTP, Message Queues etc.

9 Flow languages

ƒ Describe the ordering of interactions between services. • Client based programming to control business processes (no centralized server). • Examples: ‰ Business Process Modeling Language (BPML) ‰ Business Process Execution Language (BPEL)

Building Blocks (SOAP)

9XML based messaging framework designed to act as application-to-application protocol 9Provides serialization formats for basic data types 9Standard way of doing XML-RPC 9Does not mandate the transport protocol ƒ Only HTTP binding is defines as standard

9

SOAP Functionality

Contents of a SOAP Message

9A SOAP Envelope that describes the message

and tells how the message should be processed 9Encoding rules to describe how applicationdefined data types are encoded 9Elements that describe the desired remote procedure calls and responses

10

SOAP Message

SOAP Envelope

11

SOAP Request/Response

Building blocks (WSDL)

9XML application designed to describe messages, operations and protocol mappings of a Web Service

12

WSDL

The Components of WSDL

13

WSDL Basic Service Description

WSDL 9 Message

ƒ Abstract definition of the data in the form of a message ƒ presented either as an entire document or in the form of arguments to be mapped to a method invocation

9 Types

ƒ Defines data types to be used in the messages ƒ Typically in the form of XML Schemas, although WSDL allows other mechanisms

ƒ Elements or the data structures that will be contained in a message.

9 Operation

ƒ Abstract definition of the operation for a message ƒ Naming a method, message queue, or business process that will accept and process the message

14

WSDL (contd.) 9 Port Type ƒ

9

Represents a set of operations that are implemented by some service provider residing at some location. ƒ Define the possible operations for any number of service providers who provide a common service. ƒ Similar to an abstract interface. ƒ Can be mapped to multiple transports through different bindings. Binding ƒ Defines how an operation is bound to a protocol. ƒ Combination of a protocol and data format for a port type defines how the port type is mapped on to a particular transport ƒ Any protocol can be used to bind messages; however, SOAP, HTTP GET/POST and MIME message binding formats are defined in the spec.

WSDL (Contd.) 9 Port ƒ

A combination of a binding and a network address, that provides the target address of the service communication. The ports define the actual network end-point that associates a binding with a protocol specific address. 9 Service ƒ This is a collection of related endpoints encompassing the service definitions in the file; services map the binding to the port (in short, a service is a collection of ports).

15

Building blocks (UDDI)

9A repository for discovering and registering the

Web Service descriptions 9UDDI data categories ƒ White Pages – address, contact, and known identifiers ƒ Yellow Pages – industrial categorizations based on standard taxonomies ƒ Green Pages – technical information about services that are exposed by the business

UDDI 9 UDDI data structures

ƒ ƒ ƒ ƒ

Business Entity Business Service Specification Pointers Service Types

16

UDDI Structures and their Elements

UDDI-WSDL mapping

17

EJB 2.1 Architecture

9Main addition is incorporation of Web Services into the architecture ƒ Make EJB components easy to use as implementations for Web Services

Implementing a Web Service in EJB

9Stateless Session Bean is service endpoint 9Define web service endpoint interface ƒ Maps to WSDL definition ƒ JAX-RPC interface

9Implement business methods in bean class 9Invocations on service endpoint are delegate to stateless session bean instance ƒ JAX-RPC runtime handles mapping

18

Web Service Endpoint Interface Example

public interface StockQuoteProvider extends java.rmi.Remote { public float getLastTradePrice(String tickerSymbol) throws java.rmi.RemoteException; ... }

Web Service Endpoint Interface

9Follows rules for JAX-RPC interfaces

ƒ Cannot pass EJB Objects as arguments or

results ƒ JAX-RPC serialization rules for value types 9Declare in deployment descriptor for session bean using service-endpoint element 9Transaction attributes ƒ Web services cannot have transaction context so Mandatory doesn’t make sense

19

Stateless Session Bean Class

public class StockQuoteProviderBean implements javax.ejb.SessionBean { public float getLastTradePrice(String tickerSymbol) { // business logic for method... } //... }

Using a Web Service from an EJB

9Sending/Receiving messages looks like RPC 9Service-ref deployment descriptor 9Look up service stub in JNDI 9Get stub/proxy for service endpoint 9Invoke methods on endpoint 9JAX-RPC runtime in container handles invocations on service endpoint, data type mappings, etc.

20

EJB Client Web Service Invocation Example public class InvestmentBean implements javax.ejb.SessionBean { public void checkPortfolio(...) { Context ctx = new InitialContext(); StockQuoteService sqs = ctx.lookup( “java:comp/env/service/StockQuoteService”); StockQuoteProvider sqp = sqs.getStockQuoteProviderPort(); float quotePrice = sqp.getLastTradePrice(...); ... } ... }

References

9Wireless Java Programming for Enterprise

Applications, Chapter 14, Harkey, Appajodu,

Larkin, (Wiley 2002) 9http://servlet.java.sun.com/javaone/sf2003/conf /sessions/index.en.jsp (see ts-2255)

21

Related Documents

Web Services
November 2019 38
Web Services
November 2019 48
Web Services
November 2019 43
Web Services
November 2019 37
Web Services
December 2019 33
Web Services
November 2019 36

More Documents from ""

Web Services Slides
November 2019 13
Wsdlcontracts
November 2019 13
Jax-ws
November 2019 13
Wsdl11soap12
November 2019 17
Hibernate Join Fetch
October 2019 19