Top Banner
Web Services Development in WebSphere v5 by Tapas Banerjee CEO, Web Age Solutions Inc.
34
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Web Services Development in WebSphere v5 by Tapas Banerjee CEO, Web Age Solutions Inc.

Web Services Development in WebSphere v5

byTapas Banerjee

CEO, Web Age Solutions Inc.

Page 2: Web Services Development in WebSphere v5 by Tapas Banerjee CEO, Web Age Solutions Inc.

What are Web Services?

Applications that can be published, located and invoked programmatically over the Web.

XML-based (XML-in, XML-out).

Self-contained functions that can be used individually to provide services.

Good applications:– Business Information.

– Business Integration

– Business Process Externalization.

Page 3: Web Services Development in WebSphere v5 by Tapas Banerjee CEO, Web Age Solutions Inc.

Service Oriented Architecture

A service-oriented architecture is created by services communicating with each other

The SOA architecture allows– Different systems and programming languages to

talk to each other– Describes the service interface clearly– Allows search for needed services

It’s made up of - service provider, service broker and service requestor

Web Services implement this architecture

Page 4: Web Services Development in WebSphere v5 by Tapas Banerjee CEO, Web Age Solutions Inc.

Web Services Supporting Architecture Standards

Web Services rely on:– XML (eXtensible Markup Language).– UDDI (Universal Description Discovery and

Integration).● Publish and discover.

– SOAP (Simple Object Access Protocol).● Query UDDI, binding and use of services.

– WSDL (Web Services Description Language).

● Describe the interfaces of Web Services.

Page 5: Web Services Development in WebSphere v5 by Tapas Banerjee CEO, Web Age Solutions Inc.

The Functions and Information Flow

Web Service Client4. Request/Response via SOAP

1. Publish 3. Discover

Service Provider Service Consumer

2. Assign a unique ID and populate the registry

Service Broker

UDDI Registry

Page 6: Web Services Development in WebSphere v5 by Tapas Banerjee CEO, Web Age Solutions Inc.

Web Services Programming Model

RPC-based: Service-specific. Synchronous model. Similar to RMI and DCOM.

Message-based: Document-driven. Asynchronous model.

Page 7: Web Services Development in WebSphere v5 by Tapas Banerjee CEO, Web Age Solutions Inc.

Web Services Programming APIs

APIs for RPC-based Web Services: Sun’s JAX-RPC (Java API for XML-RPC) in WSDP. Apache’s SOAP-RPC (Apache SOAP 2.3 ships with

WAS5)

APIs for Message-based Web Services: Sun’s JAXM (Java API for XML Messaging) in WSDP. Apache’s SOAP-Message.

APIs for publishing and discovering Web Services:

Sun’s JAXR(Java API for XML Registry) in WSDP. IBM’s UDDI4J.

Page 8: Web Services Development in WebSphere v5 by Tapas Banerjee CEO, Web Age Solutions Inc.

JAXR – Java API for XML Registry

Enables Java programs to access XML registries.

JAXR provider:– Accesses XML registry.– A façade to a registry provider.

JAXR client:– A client program that accesses an XML registry using JAXR

API.– Perform queries and update UDDI registries.

Sun’s registry browser– Included in WSDP download.– Is a JAXR client with GUI.– Allows to publish and search XML registries.

Page 9: Web Services Development in WebSphere v5 by Tapas Banerjee CEO, Web Age Solutions Inc.

Other Web Services Concepts

Several other important Web Services concepts:– Web Services Invocation Framework– Web Services Inspection Language (WS-

Inspection)– Workflows– Web Services Gateway– Web Services Security

Page 10: Web Services Development in WebSphere v5 by Tapas Banerjee CEO, Web Age Solutions Inc.

Web Services Invocation FrameworkWeb Services Invocation Framework

(WSIF) – A framework for the simple invocation of

Web Services over a Java API.– Allows for maximum flexibility and late

(even runtime) binding for clients

Page 11: Web Services Development in WebSphere v5 by Tapas Banerjee CEO, Web Age Solutions Inc.

Web Services Inspection Language (WS Inspection)A complementary technology to UDDI

A service discovery mechanism

XML-based model for building a list of references to existing Web Service descriptors

Page 12: Web Services Development in WebSphere v5 by Tapas Banerjee CEO, Web Age Solutions Inc.

Workflow and Web Services

A Workflow description allows a process to be described as a sequence of discrete events (e.g. service calls)

A workflow engine can then parse the workflow description and execute the sequence automatically

Defines a business process

Page 13: Web Services Development in WebSphere v5 by Tapas Banerjee CEO, Web Age Solutions Inc.

Workflow Languages

There are three web services workflow languages:– Web Services Flow Language (WSFL)

● XML-based

– Flow Definition Markup Language (FDML)● Similar to WSFL, but with extensions

– Business Process Execution Language For Web Services (BPEL4WS)

● A meeting of IBM's WSFL and Microsoft's XLANG

Page 14: Web Services Development in WebSphere v5 by Tapas Banerjee CEO, Web Age Solutions Inc.

Web Services Gateway (WSGW)The WSGW acts as an additional layer

between a web service client, and a web service provider

Server side

Allows for better control over web service communication

Page 15: Web Services Development in WebSphere v5 by Tapas Banerjee CEO, Web Age Solutions Inc.

The Gateway Administrative Console

Page 16: Web Services Development in WebSphere v5 by Tapas Banerjee CEO, Web Age Solutions Inc.

Security Needs

Since web services are inherently network based (and typically Internet-based), security is crucial

Additionally, web service communication can be compromised at many levels

Page 17: Web Services Development in WebSphere v5 by Tapas Banerjee CEO, Web Age Solutions Inc.

SOAP HTTP Request Example

POST /SampleWebServiceWeb/servlet/rpcrouter HTTP/1.0Host: localhost:9080Content-Type: text/xml; charset=utf-8Content-Length: 526SOAPAction: ""

<?xml version='1.0' encoding='UTF-8'?><SOAP-ENV:Envelope

xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<SOAP-ENV:Body><ns1:findDepartmentByName

xmlns:ns1="http://tempuri.org/webservice.ejb.EmployeeDirectory" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">

<departmentName xsi:type="xsd:string">Sales</departmentName></ns1:findDepartmentByName></SOAP-ENV:Body></SOAP-ENV:Envelope>

Page 18: Web Services Development in WebSphere v5 by Tapas Banerjee CEO, Web Age Solutions Inc.

SOAP HTTP Response Example

HTTP/1.1 200 OKServer: WebSphere Application Server/5.0Set-Cookie: JSESSIONID=000050K5KBO5DKK1CC4A2J2VKIY:-1;Path=/Cache-Control: no-cache="set-cookie,set-cookie2"Expires: Thu, 01 Dec 1994 16:00:00 GMTContent-Type: text/xml; charset=utf-8Content-Length: 659Content-Language: en-USConnection: close

<?xml version='1.0' encoding='UTF-8'?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"

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

<SOAP-ENV:Body><ns1:findDepartmentByNameResponse

xmlns:ns1="http://tempuri.org/webservice.ejb.EmployeeDirectory" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">

<return xmlns:ns2="http://bean.webservice/" xsi:type="ns2:Department"><location xsi:type="xsd:string">Toronto</location><name xsi:type="xsd:string">Sales</name></return></ns1:findDepartmentByNameResponse>

</SOAP-ENV:Body></SOAP-ENV:Envelope>

Page 19: Web Services Development in WebSphere v5 by Tapas Banerjee CEO, Web Age Solutions Inc.

Different SOAP Implementations SOAP4J - A Java reference implementation of

the SOAP 1.1 specification. It now became the basis of the Apache SOAP 3.x project, also called Axis.

Apache SOAP 2.3– Ships with WebSphere V5

– Important elements are● Rpcrouter and messagerouter servlets● The deployment descriptor● Type mapping registry

Page 20: Web Services Development in WebSphere v5 by Tapas Banerjee CEO, Web Age Solutions Inc.

What is WSDL?

WSDL is an XML-based language for defining available Web Services and describing how to access the services, including URL endpoint, message format, encoding and required protocol.

Similar to IDL (Interface Definition Language) for CORBA, describing the services and how to use the services

WSDL 1.1 is the current standard.

Tools available to generate WSDL files.

Page 21: Web Services Development in WebSphere v5 by Tapas Banerjee CEO, Web Age Solutions Inc.

UDDI Data Structure

Five data structure types:– businessEntity– businessServic

e– bindingTempla

te– publisherAsser

tion– tModel

<businessEntity>name, contact, identificationdescription, category

<businessService> (1..n) name description

<bindingTemplate>

<tModel>NameDescriptionURL pointer to specification

<businessEntity>name, contact, identificationdescription, category

<businessService> (1..n) name description

<bindingTemplate>

<publisherAssertion>Namedescription

reference

Page 22: Web Services Development in WebSphere v5 by Tapas Banerjee CEO, Web Age Solutions Inc.

UDDI4J

IBM’s UDDI4J is a Java-based UDDI client API.

It provides package/classes for accessing UDDI registry (publishing and discovering).

UDDIProxy object is the client side proxy of the registry.

Program the UDDIProxy for publishing/discovering services.

Page 23: Web Services Development in WebSphere v5 by Tapas Banerjee CEO, Web Age Solutions Inc.

Developing Web Services

Generate deployable web service from– Java Bean– DADX (XML/DB2 mapping documents)– Enterprise Java Bean– URL

Generate skeleton Java Bean and sample application from WSDL document

Web Services Client wizard also creates– Web Service Proxy as Java Bean– Sample JSP-based client application

Page 24: Web Services Development in WebSphere v5 by Tapas Banerjee CEO, Web Age Solutions Inc.

Overall Workflow

Typical development path

1. Create a Web Project

2. Create/Import a resource from which to create a web service (Java Bean, EJB, DADX document, …)

3. Create a Web Service using Web Service Wizard

4. Publish a Business Entity, if required

5. Publish the Web Service

Page 25: Web Services Development in WebSphere v5 by Tapas Banerjee CEO, Web Age Solutions Inc.

Creating a Web Service from a Java Bean Typical steps:

1. Create/Import Java Bean into Web Project

2. Generate binding WSDL document using Web Service Wizard

3. Deploy Web Service to a Web Server

4. Generate client proxy

5. Generate sample client application

Then publish, discover and use web service

Page 26: Web Services Development in WebSphere v5 by Tapas Banerjee CEO, Web Age Solutions Inc.

… from an EJB

Typical steps:

1. Create a Web Project

2. Create/Import EJBs into an EJB Project belonging to the same Enterprise Application Project as the Web Project

3. Update project dependencies

… then it’s “business as usual”

WSAD only generates a Web Service from a Stateless Session EJB– … but that session bean can always use entity beans!

Page 27: Web Services Development in WebSphere v5 by Tapas Banerjee CEO, Web Age Solutions Inc.

Web Service Development Phases

Build– May start from Java code, then we generate

WSDL from that– Or start from WSDL and build/morph Java code

to match

Deployment– We can publish using

● UDDI, WSIL or E-mailing customers

Run Management

Page 28: Web Services Development in WebSphere v5 by Tapas Banerjee CEO, Web Age Solutions Inc.

Different web service creation paths From an existing application – bottom-up

– Most common. We like to expose existing back-end systems for enterprise integration (EAI) purposes.

From WSDL, generate a completely new application – top-down– This may be due to a new spec imposed by a

governing body– The wizards can create skeleton code from WSDL, we

then fill up the details

Combine independent web services to provide new functionality. This route is similar to the façade design pattern.

Page 29: Web Services Development in WebSphere v5 by Tapas Banerjee CEO, Web Age Solutions Inc.

Different WebSphere products – how do they fare? There are three products in the WebSphere

family that can be used– WSAD– WSAD IE– WebSphere SDK for web services (WSDK) family

All three can do bottom-up and top-down from JavaBeans

WSAD IE and WSDK can do bottom-up and top-down from EJB’s– Regular WSAD cannot do top-down for EJB’s I.e.

cannot create EJB’s from WSDL.

Page 30: Web Services Development in WebSphere v5 by Tapas Banerjee CEO, Web Age Solutions Inc.

… from XML schema

Generate Java Bean from XML schema1. Create any project that works with Java

source code (Java, EJB, Web, …)

2. Create/Import XML schema in the project

3. Start Web Services Wizard

4. Select Java beans for XML Schema.

5. Follow instructions to generate Java Beans Now generate the Web Service from

the new Java Bean

Page 31: Web Services Development in WebSphere v5 by Tapas Banerjee CEO, Web Age Solutions Inc.

WSDK 5.0

WebSphere SDK for Web Services– Entry level developer kit, free for development

– But not for production or deployment

– Runs on Windows 2000/XP and Linux

– Based on Axis (Apache SOAP engine)

– Has embedded application server (mini WebSphere 5.0) and a private UDDI registry

– Supports SOAP 1.1, WSDL 1.1, UDDI 2.0, JAX_RPC 1.0, WSDL4J, UDDI4J and WS-Security

Page 32: Web Services Development in WebSphere v5 by Tapas Banerjee CEO, Web Age Solutions Inc.

ETTK (previously called WSTK)

IBM Emerging Technologies Toolkit (previously called Web Services toolkit)

An IBM alphaworks technology, showcases technologies to come

Exposes the AXIS programming model WSTK version 3.2.2 includes

– WS-C/WS-Tx for transaction flows between components– Web Services matchmaking engine – Businesses submit

advertisements. When a customers search matches an advertisement, a response is triggered

– WSXL – For better handshaking of web services with portal applications

Page 33: Web Services Development in WebSphere v5 by Tapas Banerjee CEO, Web Age Solutions Inc.

Web Services Deployment in WebSphereIf you are using WSAD 5, it is same as

deploying an EAR file

If you are using WSAD 4– Export the Web Service as a WAR– Use AAT to create an EAR– Use soapearenabler.bat to add SOAP

services

Page 34: Web Services Development in WebSphere v5 by Tapas Banerjee CEO, Web Age Solutions Inc.

Summary

We discussed– What are Web Services.– Web Services programming model.– How does a SOAP message look.– Developing Web Services.– Web Service Development Phases.