Top Banner
Developing service component architecture applications using Rational Application Developer Skill Level: Intermediate Lokanadham Nalla ([email protected]) Author1 job title IBM 27 Dec 2010 This article describes how to develop and access SCA applications using Rational Application Developer Version 8 with a sample application. It begins with some basic definitions and frequently used terms used, next we describe the pre-requisites and references links before start developing SCA applications. Next explains with the wizards of the Rational Application Developer to create a sample SCA application, create different supported bindings for SCA Services and SCA References like default SCA binding, web services binding, and EJB bindings. The article concludes by describing how Servlet client application accesses the SCA sample application. Overview Service Component Architecture (SCA) is a programming model for SOA based application development. The specifications for implementing the SCA programming model are provided by osoa.org, an open SOA collaboration from industry leaders including IBM. The SCA Feature Pack for WebSphere Application Server implemented many of the specifications provided by the osoa.org to provide SCA programming model for Java/JEE developers. Rational Application Developer (RAD) Version 8 provides the tooling facility to develop SCA applications. This article describes how to develop SCA applications using RAD with a sample application demonstrating supported SCA bindings. We begin with the basic definitions of SCA, required software, developing a simple SCA application and finally using it from different types of SCA client applications. Basic SCA definitions Developing service component architecture applications using Rational Application Developer Trademarks © Copyright IBM Corporation 2010. All rights reserved. Page 1 of 30
30

Developing service component architecture applications using rational application developer

Oct 19, 2014

Download

Technology

Summary: This article describes how to develop and access SCA applications using Rational Application Developer Version 8 with a sample application. It begins with some basic definitions and frequently used terms used, next we describe the pre-requisites and references links before start developing SCA applications. Next explains with the wizards of the Rational Application Developer to create a sample SCA application, create different supported bindings for SCA Services and SCA References like default SCA binding, web services binding, and EJB bindings. The article concludes by describing how Servlet client application accesses the SCA sample application.
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: Developing service component architecture applications using rational application developer

Developing service component architectureapplications using Rational Application DeveloperSkill Level Intermediate

Lokanadham Nalla (loknallainibmcom)Author1 job titleIBM

27 Dec 2010

This article describes how to develop and access SCA applications using RationalApplication Developer Version 8 with a sample application It begins with some basicdefinitions and frequently used terms used next we describe the pre-requisites andreferences links before start developing SCA applications Next explains with thewizards of the Rational Application Developer to create a sample SCA applicationcreate different supported bindings for SCA Services and SCA References likedefault SCA binding web services binding and EJB bindings The article concludesby describing how Servlet client application accesses the SCA sample application

Overview

Service Component Architecture (SCA) is a programming model for SOA basedapplication development The specifications for implementing the SCA programmingmodel are provided by osoaorg an open SOA collaboration from industry leadersincluding IBM The SCA Feature Pack for WebSphere Application Serverimplemented many of the specifications provided by the osoaorg to provide SCAprogramming model for JavaJEE developers

Rational Application Developer (RAD) Version 8 provides the tooling facility todevelop SCA applications This article describes how to develop SCA applicationsusing RAD with a sample application demonstrating supported SCA bindings Webegin with the basic definitions of SCA required software developing a simple SCAapplication and finally using it from different types of SCA client applications

Basic SCA definitions

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 1 of 30

This section describes SCA terminology extracted from the RAD 8 InformationCenter

DomainA well-bounded runtime entity that contains a set of service components wiredtogether to provide a realm of business function that is meaningful to a business

ContributionA package of file artifacts including a contribution metadata document and usuallyone or more composites collected together for deployment to an SCA domain

ComponentA configuration of an implementation that provides or consumes services

CompositeA unit of assembly of components Composites may be deployed to a domain andbecome known as deployable composites or used to implement other componentsand become known as implementation composites or inner composites

ServiceA declaration of a service or set of business operations offered by a component Aservice is characterized by an interface and by one or more protocol bindings

ReferenceA declaration of a service or set of business operations consumed or required by acomponent A reference is characterized by an interface and by one or moreprotocol bindings

InterfaceA logically cohesive set of operation signatures describing a service provided or aservice reference consumed Though other languages are allowed through theextensibility of SCA predominantly interfaces are written in either Java or WSDL

BindingA description of an access mechanism to a service or from a reference A servicebinding describes how a service is published at runtime and how external entitiescan communicate with it A reference binding describes how a reference connects toand communicates with external services

WireA dependency from a component reference to a component service

ImplementationA unit of language-specific software technology such as a Java class or an SCAcomposite that provides the business logic beneath a component

Property

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 2 of 30

A data value computed and injected by a component into an implementation

IntentA declaration of an abstract policy or quality of service required of a componentservice or reference Intents relieve the developer of the burden of having tounderstand frequently complex concrete policies

PolicyA concrete assertion of some capability constraint or other non-functionalrequirement to be honored by a component service or reference

Policy SetA collection of mutually compatible concrete policies that can be applied to a specificbinding type or implementation type Although policy sets can be attached tocomponents services and references at development time SCA recommends a latebinding approach in which policy sets and bindings are selected at deployment time

Installation

This section provides information on the installation of Rational ApplicationDeveloper 80 for WebSphere Application Server software

bull The Information Center for IBM Rational Application Developer 80 andWebSphere Application Server provides additional details on theinstallation steps

bull Ensure the Service Component Architecture development tools featureis enabled from the list of features during RAD installation using IBMInstallation Manager Software as highlighted in Figure 1

Figure 1 Service Component Architecture development tools

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 3 of 30

bull Also ensure Feature Pack for Service Component Architecture isenabled under WebSphere Application Server section as highlighted infigure 2 below

Figure 2 Feature Pack for Service Component Architecture

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 4 of 30

Installing SCA Feature Pack

This section provides information on SCA Feature Pack installation if theWebSphere Application Server is installed external to RAD

To install the Service Component Architecture (SCA) Feature Pack you need tocomplete the instructions provided in the section Installing and uninstalling thefeature pack on distributed operating systems in the WebSphere Application ServerInformation Center

Developing SCA applications using RAD

This section describes the tasks required to develop a sample SCA calculatorapplication using RAD wizards

bull Create SCA Project

bull Create SCA Composite

bull Create SCA Component

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 5 of 30

bull Adding service or reference to a Component

bull Apply binding to a service or reference

bull Component implementation

bull Create Contribution

Creating a SCA project

This section describes how to create a new SCA project using RAD wizards FromRAD workspace open menu options File gt New gt Other Select SCA Project asshown in Figure 3

Figure 3 Create SCA Project

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 6 of 30

Specify project name as CalculatorProject as shown in Figure 4 below and makesure Implementation Types for SCA Components section Java checkbox isenabled

Figure 4 SCA Project Options

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 7 of 30

Click Next gt Finish buttons to create CalculatorProject

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 8 of 30

Create SCA Composite

Expand the CalculatorProject gt SCA Content from the Enterprise Explorer windowand right click on Composites select New gt SCA Composite as shown is Figure 5

Figure 5 Create SCA Composite

Specify Composite name as CalculatorComposite and Target namespace ashttpcalculator as shown in Figure 6 and click on Finish button

Figure 6 SCA Composite options

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 9 of 30

Create SCA Component

Expand CalculatorProject gt SCA Content gt Composites gt httpcalculator gt andright click on CalculatorComposite Select option New gt SCA Component as shownin Figure 7

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 10 of 30

Figure 7 Create SCA Component

Specify Component name as MainComponent as specified in Figure 8 and click onFinish button

Figure 8 SCA Component options

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 11 of 30

MainComponent image is created on the composite diagram as shown in Figure 9

Figure 9 MainComponent

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 12 of 30

Adding service or reference to a Component

Right click on the MainComponent image to create a service and a reference asshown in Figure 10 and Figure 11 Name the service as CalculatorInterface and thereference as addReference

Figure 10 Adding a service

Figure 11 Adding a reference

There are two approaches for SCA service implementation top-down and

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 13 of 30

bottom-up Top-down development is used when starting with an existing WSDLBottom-up development is used when starting from existing Java code The sampleuses bottom-up approach where service Interface type is set to Java

bull Create package comibmscasample under src folder of theCalculatorProject

bull Create a new Java interface as shown in Listing 1

Listing 1 Service Interface

package comibmscasample

import orgosoascaannotationsRemotable

Remotablepublic interface CalculatorInterface

int calculate(int firstValue int secondValue String operation)

bull Make sure you have Remotable annotation is added to the interface

bull Set the service Interface property tocomibmscasamplesCalculatorInterface as highlighted in Figure 12

Figure 12 Set service interface

Note If top-down approach is used select Interface type as WSDL and specify thelocation of the WSDL in Interface

Apply binding to a service or reference

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 14 of 30

The SCA Feature Pack supports following bindings

bull Web service

bull Atom

bull HTTP

bull EJB

bull JMS

bull SCA

Users can choose to apply these binding depending on the type of client they areusing If the client application is a web service client then web service binding canbe applied If the client application is EJB client EJB bindings can be applied

In the Calculator sample application the web service binding is used so that theclient Servlet application can use the generated WSDL file for communication withCalculator SCA application Follow the below steps for applying web service bindingto the CalculatorInterface service

bull Right click on the CalculatorInterface service select Show PropertiesView option from the menu panel which displays the properties windowas shown in bottom panel of Figure 13

bull Select Binding option from the left pane of the properties window

bull List of SCA Feature Pack supported bindings are displayed after clickingon Add button on the Bindings as shown in Figure 13

bull Select web service from the list of bindings and click OK Now the webservice client APIs can be used to invoke the SCA Calculator application

bull When the Calculator application is deployed into WebSphere ApplicationServer It generates a WSDL file and it can be located using followingURLhttpserver-namehttp-portMainComponentCalculatorInterfacewsdl

Figure 13 Service properties and bindings

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 15 of 30

Similarly bindings can also be applied for a reference

Component implementation

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 16 of 30

Right click on the MainComponent and select Regenerate implementation optionas shown in Figure 14

Figure 14 Generate Implementation

bull Choose Java from the list of Implementation Type in the next window

bull Click the Next button and observe the implementation class it is going tobe generated as highlighted in Figure 15

bull Click on the Finish button to generate the implementation classcomibmscasamplesCalculatorInterfaceImpl

Figure 15 Implementation class configuration

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 17 of 30

Listing 2 below shows the generated implementation class

Listing 2 Implementation class

package comibmscasample

import orgosoascaannotationsService

Service (CalculatorInterfaceclass)public class CalculatorInterfaceImpl implements CalculatorInterface

public int calculate(int firstValue int secondValue String operation) return 0

The created reference needs to be defined in the component implementation Inother words we mandated MainComponent to have reference and it depends on

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 18 of 30

some other components service So a new component (AddComponent) with aservice need to be created and map the MainComponent reference to the service ofAddComponent as highlighted in Figure 16

Figure 16 Wiring MainComponent reference to AddComponent service

bull The steps for creating AddComponent and service are similar toMainComponent

bull The MainComponent implementation should have reference definition asshown in Listing 3

Listing 3 Reference definition

AddInterface addInterface

Referencepublic void setAddReference(AddInterface addInterface)

thisaddInterface=addInterface

bull MainComponent reference and AddComponent service should be boundto SCA binding as shown in properties window of Figure 18 This is notmandatory by default if not chosen any bindings for a service orreference default SCA bindings are applied automatically

bull The AddComponent implementation class should be as shown in Listing4

Listing 4 AddComponent implementation

package comibmscasampleimport orgosoascaannotationsService

Service (AddInterfaceclass)public class AddInterfaceImpl implements AddInterface

public int add(int firstValue int secordValue) return firstValue+secordValue

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 19 of 30

Similarly SubstractComponent MultiplyComponent and DivisionComponent and itsservices can be created and wired to the MainComponents different referencesUpon creating all the above components the Calculator SCA composite diagramshould look as shown in Figure 17

Figure 17 Calculator SCA composite diagram

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 20 of 30

Create Contribution

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 21 of 30

Contribution can be created for the Calculator composite using RAD wizards asshown in Figure 18

Figure 18 Creating Contribution

Once the contribution is created it can be added to deploy on the local WebSphereApplication Server instance as shown in Figure 19 and Figure 20

Figure 19 AddingRemoving projects

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 22 of 30

Figure 20 Adding Calculator project

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 23 of 30

Note The contribution can also be exported as SCA archive file for deployment intoWebSphere Application Server external to the RAD

Servlet client using SCA Calculator application

This section describes how to use the Calculator SCA applicationMainComponenent service from a Servlet application

bull Create a Dynamic Web project from the RAD workspace

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 24 of 30

bull Make sure the WSDL can be located athttpserver-namehttp-portMainComponentCalculatorInterfacewsdl

Create the WSDL stub classes using following steps

1 Open File gt New gt Other and select Web service client project

2 Specifyhttpserver-namehttp-portMainComponentCalculatorInterfacewsdl inthe service definition

3 Specify the Develop client as highlighted in Figure 21 and click Nextbutton

Figure 21 Web service client

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 25 of 30

4 Specify the package comibmscastubs as shown in Figure 22 and clickon Finish

Figure 22 Specify stub classes package

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 26 of 30

The Servlet can use the code as highlighted in Listing 5 below

Listing 5 Web service stub APIs

import comibmscastubsCalculatorInterfaceimport comibmscastubsCalculatorInterfaceServiceCalculatorInterfaceService service = new CalculatorInterfaceService()CalculatorInterface ci = (CalculatorInterface) servicegetCalculatorInterfacePort()

int result = cicalculate(firstValue secondValue operation)

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 27 of 30

Working with supplied sample

This section describes the steps required to deploy the Calculator SCA sample anddeploying the SCA Servlet client application and working with it

bull Download and extract the downloadzip file located in the downloadsection

bull Run the following command to deploy the SCA application as BLA andalso deploying the Servlet client

bull Unix platformswsadminsh ndashf deploypy

bull Windows platformwsadminbat ndashf deploypy

bull To undeploy the samples run the following command

bull Unix platformswsadminsh ndashf undeploypy

bull Windows platformwsadminbat ndashf undeploypy

bull To run the sample application open the following URLhttpserver-namehttp-portSCAClient

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 28 of 30

Downloads

Description Name Size Downloadmethod

Sample downloads scripts for thisarticle

DoNotLeaveThisLinkzip 10KB HTTP

Information about download methods

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 29 of 30

Resources

bull Rational Application Developer Information Center

bull Education Assistant for WebSphere Application Server V70 Feature Pack forService Component Architecture

bull Exploring the WebSphere Application Server Feature Pack for SCA Part 1 Anoverview of the Service Component Architecture feature pack (Dec 2008) is anintroduction to open Service Component Architecture (SCA) conceptsobjectives of the technology and highlights of some key integration points

About the author

Lokanadham NallaLokanadham Nalla is a TXSeries Developer located in India SoftwareLabs Bangalore India with expertise in Java J2EE and SOAtechnologies

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 30 of 30

  • Table of Contents
  • Overview
  • Installation
  • Developing SCA applications using RAD
  • Servlet client using SCA Calculator application
  • Working with supplied sample
  • Downloads
  • Resources
  • About the author
Page 2: Developing service component architecture applications using rational application developer

This section describes SCA terminology extracted from the RAD 8 InformationCenter

DomainA well-bounded runtime entity that contains a set of service components wiredtogether to provide a realm of business function that is meaningful to a business

ContributionA package of file artifacts including a contribution metadata document and usuallyone or more composites collected together for deployment to an SCA domain

ComponentA configuration of an implementation that provides or consumes services

CompositeA unit of assembly of components Composites may be deployed to a domain andbecome known as deployable composites or used to implement other componentsand become known as implementation composites or inner composites

ServiceA declaration of a service or set of business operations offered by a component Aservice is characterized by an interface and by one or more protocol bindings

ReferenceA declaration of a service or set of business operations consumed or required by acomponent A reference is characterized by an interface and by one or moreprotocol bindings

InterfaceA logically cohesive set of operation signatures describing a service provided or aservice reference consumed Though other languages are allowed through theextensibility of SCA predominantly interfaces are written in either Java or WSDL

BindingA description of an access mechanism to a service or from a reference A servicebinding describes how a service is published at runtime and how external entitiescan communicate with it A reference binding describes how a reference connects toand communicates with external services

WireA dependency from a component reference to a component service

ImplementationA unit of language-specific software technology such as a Java class or an SCAcomposite that provides the business logic beneath a component

Property

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 2 of 30

A data value computed and injected by a component into an implementation

IntentA declaration of an abstract policy or quality of service required of a componentservice or reference Intents relieve the developer of the burden of having tounderstand frequently complex concrete policies

PolicyA concrete assertion of some capability constraint or other non-functionalrequirement to be honored by a component service or reference

Policy SetA collection of mutually compatible concrete policies that can be applied to a specificbinding type or implementation type Although policy sets can be attached tocomponents services and references at development time SCA recommends a latebinding approach in which policy sets and bindings are selected at deployment time

Installation

This section provides information on the installation of Rational ApplicationDeveloper 80 for WebSphere Application Server software

bull The Information Center for IBM Rational Application Developer 80 andWebSphere Application Server provides additional details on theinstallation steps

bull Ensure the Service Component Architecture development tools featureis enabled from the list of features during RAD installation using IBMInstallation Manager Software as highlighted in Figure 1

Figure 1 Service Component Architecture development tools

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 3 of 30

bull Also ensure Feature Pack for Service Component Architecture isenabled under WebSphere Application Server section as highlighted infigure 2 below

Figure 2 Feature Pack for Service Component Architecture

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 4 of 30

Installing SCA Feature Pack

This section provides information on SCA Feature Pack installation if theWebSphere Application Server is installed external to RAD

To install the Service Component Architecture (SCA) Feature Pack you need tocomplete the instructions provided in the section Installing and uninstalling thefeature pack on distributed operating systems in the WebSphere Application ServerInformation Center

Developing SCA applications using RAD

This section describes the tasks required to develop a sample SCA calculatorapplication using RAD wizards

bull Create SCA Project

bull Create SCA Composite

bull Create SCA Component

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 5 of 30

bull Adding service or reference to a Component

bull Apply binding to a service or reference

bull Component implementation

bull Create Contribution

Creating a SCA project

This section describes how to create a new SCA project using RAD wizards FromRAD workspace open menu options File gt New gt Other Select SCA Project asshown in Figure 3

Figure 3 Create SCA Project

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 6 of 30

Specify project name as CalculatorProject as shown in Figure 4 below and makesure Implementation Types for SCA Components section Java checkbox isenabled

Figure 4 SCA Project Options

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 7 of 30

Click Next gt Finish buttons to create CalculatorProject

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 8 of 30

Create SCA Composite

Expand the CalculatorProject gt SCA Content from the Enterprise Explorer windowand right click on Composites select New gt SCA Composite as shown is Figure 5

Figure 5 Create SCA Composite

Specify Composite name as CalculatorComposite and Target namespace ashttpcalculator as shown in Figure 6 and click on Finish button

Figure 6 SCA Composite options

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 9 of 30

Create SCA Component

Expand CalculatorProject gt SCA Content gt Composites gt httpcalculator gt andright click on CalculatorComposite Select option New gt SCA Component as shownin Figure 7

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 10 of 30

Figure 7 Create SCA Component

Specify Component name as MainComponent as specified in Figure 8 and click onFinish button

Figure 8 SCA Component options

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 11 of 30

MainComponent image is created on the composite diagram as shown in Figure 9

Figure 9 MainComponent

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 12 of 30

Adding service or reference to a Component

Right click on the MainComponent image to create a service and a reference asshown in Figure 10 and Figure 11 Name the service as CalculatorInterface and thereference as addReference

Figure 10 Adding a service

Figure 11 Adding a reference

There are two approaches for SCA service implementation top-down and

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 13 of 30

bottom-up Top-down development is used when starting with an existing WSDLBottom-up development is used when starting from existing Java code The sampleuses bottom-up approach where service Interface type is set to Java

bull Create package comibmscasample under src folder of theCalculatorProject

bull Create a new Java interface as shown in Listing 1

Listing 1 Service Interface

package comibmscasample

import orgosoascaannotationsRemotable

Remotablepublic interface CalculatorInterface

int calculate(int firstValue int secondValue String operation)

bull Make sure you have Remotable annotation is added to the interface

bull Set the service Interface property tocomibmscasamplesCalculatorInterface as highlighted in Figure 12

Figure 12 Set service interface

Note If top-down approach is used select Interface type as WSDL and specify thelocation of the WSDL in Interface

Apply binding to a service or reference

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 14 of 30

The SCA Feature Pack supports following bindings

bull Web service

bull Atom

bull HTTP

bull EJB

bull JMS

bull SCA

Users can choose to apply these binding depending on the type of client they areusing If the client application is a web service client then web service binding canbe applied If the client application is EJB client EJB bindings can be applied

In the Calculator sample application the web service binding is used so that theclient Servlet application can use the generated WSDL file for communication withCalculator SCA application Follow the below steps for applying web service bindingto the CalculatorInterface service

bull Right click on the CalculatorInterface service select Show PropertiesView option from the menu panel which displays the properties windowas shown in bottom panel of Figure 13

bull Select Binding option from the left pane of the properties window

bull List of SCA Feature Pack supported bindings are displayed after clickingon Add button on the Bindings as shown in Figure 13

bull Select web service from the list of bindings and click OK Now the webservice client APIs can be used to invoke the SCA Calculator application

bull When the Calculator application is deployed into WebSphere ApplicationServer It generates a WSDL file and it can be located using followingURLhttpserver-namehttp-portMainComponentCalculatorInterfacewsdl

Figure 13 Service properties and bindings

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 15 of 30

Similarly bindings can also be applied for a reference

Component implementation

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 16 of 30

Right click on the MainComponent and select Regenerate implementation optionas shown in Figure 14

Figure 14 Generate Implementation

bull Choose Java from the list of Implementation Type in the next window

bull Click the Next button and observe the implementation class it is going tobe generated as highlighted in Figure 15

bull Click on the Finish button to generate the implementation classcomibmscasamplesCalculatorInterfaceImpl

Figure 15 Implementation class configuration

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 17 of 30

Listing 2 below shows the generated implementation class

Listing 2 Implementation class

package comibmscasample

import orgosoascaannotationsService

Service (CalculatorInterfaceclass)public class CalculatorInterfaceImpl implements CalculatorInterface

public int calculate(int firstValue int secondValue String operation) return 0

The created reference needs to be defined in the component implementation Inother words we mandated MainComponent to have reference and it depends on

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 18 of 30

some other components service So a new component (AddComponent) with aservice need to be created and map the MainComponent reference to the service ofAddComponent as highlighted in Figure 16

Figure 16 Wiring MainComponent reference to AddComponent service

bull The steps for creating AddComponent and service are similar toMainComponent

bull The MainComponent implementation should have reference definition asshown in Listing 3

Listing 3 Reference definition

AddInterface addInterface

Referencepublic void setAddReference(AddInterface addInterface)

thisaddInterface=addInterface

bull MainComponent reference and AddComponent service should be boundto SCA binding as shown in properties window of Figure 18 This is notmandatory by default if not chosen any bindings for a service orreference default SCA bindings are applied automatically

bull The AddComponent implementation class should be as shown in Listing4

Listing 4 AddComponent implementation

package comibmscasampleimport orgosoascaannotationsService

Service (AddInterfaceclass)public class AddInterfaceImpl implements AddInterface

public int add(int firstValue int secordValue) return firstValue+secordValue

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 19 of 30

Similarly SubstractComponent MultiplyComponent and DivisionComponent and itsservices can be created and wired to the MainComponents different referencesUpon creating all the above components the Calculator SCA composite diagramshould look as shown in Figure 17

Figure 17 Calculator SCA composite diagram

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 20 of 30

Create Contribution

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 21 of 30

Contribution can be created for the Calculator composite using RAD wizards asshown in Figure 18

Figure 18 Creating Contribution

Once the contribution is created it can be added to deploy on the local WebSphereApplication Server instance as shown in Figure 19 and Figure 20

Figure 19 AddingRemoving projects

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 22 of 30

Figure 20 Adding Calculator project

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 23 of 30

Note The contribution can also be exported as SCA archive file for deployment intoWebSphere Application Server external to the RAD

Servlet client using SCA Calculator application

This section describes how to use the Calculator SCA applicationMainComponenent service from a Servlet application

bull Create a Dynamic Web project from the RAD workspace

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 24 of 30

bull Make sure the WSDL can be located athttpserver-namehttp-portMainComponentCalculatorInterfacewsdl

Create the WSDL stub classes using following steps

1 Open File gt New gt Other and select Web service client project

2 Specifyhttpserver-namehttp-portMainComponentCalculatorInterfacewsdl inthe service definition

3 Specify the Develop client as highlighted in Figure 21 and click Nextbutton

Figure 21 Web service client

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 25 of 30

4 Specify the package comibmscastubs as shown in Figure 22 and clickon Finish

Figure 22 Specify stub classes package

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 26 of 30

The Servlet can use the code as highlighted in Listing 5 below

Listing 5 Web service stub APIs

import comibmscastubsCalculatorInterfaceimport comibmscastubsCalculatorInterfaceServiceCalculatorInterfaceService service = new CalculatorInterfaceService()CalculatorInterface ci = (CalculatorInterface) servicegetCalculatorInterfacePort()

int result = cicalculate(firstValue secondValue operation)

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 27 of 30

Working with supplied sample

This section describes the steps required to deploy the Calculator SCA sample anddeploying the SCA Servlet client application and working with it

bull Download and extract the downloadzip file located in the downloadsection

bull Run the following command to deploy the SCA application as BLA andalso deploying the Servlet client

bull Unix platformswsadminsh ndashf deploypy

bull Windows platformwsadminbat ndashf deploypy

bull To undeploy the samples run the following command

bull Unix platformswsadminsh ndashf undeploypy

bull Windows platformwsadminbat ndashf undeploypy

bull To run the sample application open the following URLhttpserver-namehttp-portSCAClient

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 28 of 30

Downloads

Description Name Size Downloadmethod

Sample downloads scripts for thisarticle

DoNotLeaveThisLinkzip 10KB HTTP

Information about download methods

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 29 of 30

Resources

bull Rational Application Developer Information Center

bull Education Assistant for WebSphere Application Server V70 Feature Pack forService Component Architecture

bull Exploring the WebSphere Application Server Feature Pack for SCA Part 1 Anoverview of the Service Component Architecture feature pack (Dec 2008) is anintroduction to open Service Component Architecture (SCA) conceptsobjectives of the technology and highlights of some key integration points

About the author

Lokanadham NallaLokanadham Nalla is a TXSeries Developer located in India SoftwareLabs Bangalore India with expertise in Java J2EE and SOAtechnologies

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 30 of 30

  • Table of Contents
  • Overview
  • Installation
  • Developing SCA applications using RAD
  • Servlet client using SCA Calculator application
  • Working with supplied sample
  • Downloads
  • Resources
  • About the author
Page 3: Developing service component architecture applications using rational application developer

A data value computed and injected by a component into an implementation

IntentA declaration of an abstract policy or quality of service required of a componentservice or reference Intents relieve the developer of the burden of having tounderstand frequently complex concrete policies

PolicyA concrete assertion of some capability constraint or other non-functionalrequirement to be honored by a component service or reference

Policy SetA collection of mutually compatible concrete policies that can be applied to a specificbinding type or implementation type Although policy sets can be attached tocomponents services and references at development time SCA recommends a latebinding approach in which policy sets and bindings are selected at deployment time

Installation

This section provides information on the installation of Rational ApplicationDeveloper 80 for WebSphere Application Server software

bull The Information Center for IBM Rational Application Developer 80 andWebSphere Application Server provides additional details on theinstallation steps

bull Ensure the Service Component Architecture development tools featureis enabled from the list of features during RAD installation using IBMInstallation Manager Software as highlighted in Figure 1

Figure 1 Service Component Architecture development tools

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 3 of 30

bull Also ensure Feature Pack for Service Component Architecture isenabled under WebSphere Application Server section as highlighted infigure 2 below

Figure 2 Feature Pack for Service Component Architecture

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 4 of 30

Installing SCA Feature Pack

This section provides information on SCA Feature Pack installation if theWebSphere Application Server is installed external to RAD

To install the Service Component Architecture (SCA) Feature Pack you need tocomplete the instructions provided in the section Installing and uninstalling thefeature pack on distributed operating systems in the WebSphere Application ServerInformation Center

Developing SCA applications using RAD

This section describes the tasks required to develop a sample SCA calculatorapplication using RAD wizards

bull Create SCA Project

bull Create SCA Composite

bull Create SCA Component

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 5 of 30

bull Adding service or reference to a Component

bull Apply binding to a service or reference

bull Component implementation

bull Create Contribution

Creating a SCA project

This section describes how to create a new SCA project using RAD wizards FromRAD workspace open menu options File gt New gt Other Select SCA Project asshown in Figure 3

Figure 3 Create SCA Project

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 6 of 30

Specify project name as CalculatorProject as shown in Figure 4 below and makesure Implementation Types for SCA Components section Java checkbox isenabled

Figure 4 SCA Project Options

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 7 of 30

Click Next gt Finish buttons to create CalculatorProject

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 8 of 30

Create SCA Composite

Expand the CalculatorProject gt SCA Content from the Enterprise Explorer windowand right click on Composites select New gt SCA Composite as shown is Figure 5

Figure 5 Create SCA Composite

Specify Composite name as CalculatorComposite and Target namespace ashttpcalculator as shown in Figure 6 and click on Finish button

Figure 6 SCA Composite options

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 9 of 30

Create SCA Component

Expand CalculatorProject gt SCA Content gt Composites gt httpcalculator gt andright click on CalculatorComposite Select option New gt SCA Component as shownin Figure 7

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 10 of 30

Figure 7 Create SCA Component

Specify Component name as MainComponent as specified in Figure 8 and click onFinish button

Figure 8 SCA Component options

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 11 of 30

MainComponent image is created on the composite diagram as shown in Figure 9

Figure 9 MainComponent

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 12 of 30

Adding service or reference to a Component

Right click on the MainComponent image to create a service and a reference asshown in Figure 10 and Figure 11 Name the service as CalculatorInterface and thereference as addReference

Figure 10 Adding a service

Figure 11 Adding a reference

There are two approaches for SCA service implementation top-down and

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 13 of 30

bottom-up Top-down development is used when starting with an existing WSDLBottom-up development is used when starting from existing Java code The sampleuses bottom-up approach where service Interface type is set to Java

bull Create package comibmscasample under src folder of theCalculatorProject

bull Create a new Java interface as shown in Listing 1

Listing 1 Service Interface

package comibmscasample

import orgosoascaannotationsRemotable

Remotablepublic interface CalculatorInterface

int calculate(int firstValue int secondValue String operation)

bull Make sure you have Remotable annotation is added to the interface

bull Set the service Interface property tocomibmscasamplesCalculatorInterface as highlighted in Figure 12

Figure 12 Set service interface

Note If top-down approach is used select Interface type as WSDL and specify thelocation of the WSDL in Interface

Apply binding to a service or reference

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 14 of 30

The SCA Feature Pack supports following bindings

bull Web service

bull Atom

bull HTTP

bull EJB

bull JMS

bull SCA

Users can choose to apply these binding depending on the type of client they areusing If the client application is a web service client then web service binding canbe applied If the client application is EJB client EJB bindings can be applied

In the Calculator sample application the web service binding is used so that theclient Servlet application can use the generated WSDL file for communication withCalculator SCA application Follow the below steps for applying web service bindingto the CalculatorInterface service

bull Right click on the CalculatorInterface service select Show PropertiesView option from the menu panel which displays the properties windowas shown in bottom panel of Figure 13

bull Select Binding option from the left pane of the properties window

bull List of SCA Feature Pack supported bindings are displayed after clickingon Add button on the Bindings as shown in Figure 13

bull Select web service from the list of bindings and click OK Now the webservice client APIs can be used to invoke the SCA Calculator application

bull When the Calculator application is deployed into WebSphere ApplicationServer It generates a WSDL file and it can be located using followingURLhttpserver-namehttp-portMainComponentCalculatorInterfacewsdl

Figure 13 Service properties and bindings

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 15 of 30

Similarly bindings can also be applied for a reference

Component implementation

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 16 of 30

Right click on the MainComponent and select Regenerate implementation optionas shown in Figure 14

Figure 14 Generate Implementation

bull Choose Java from the list of Implementation Type in the next window

bull Click the Next button and observe the implementation class it is going tobe generated as highlighted in Figure 15

bull Click on the Finish button to generate the implementation classcomibmscasamplesCalculatorInterfaceImpl

Figure 15 Implementation class configuration

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 17 of 30

Listing 2 below shows the generated implementation class

Listing 2 Implementation class

package comibmscasample

import orgosoascaannotationsService

Service (CalculatorInterfaceclass)public class CalculatorInterfaceImpl implements CalculatorInterface

public int calculate(int firstValue int secondValue String operation) return 0

The created reference needs to be defined in the component implementation Inother words we mandated MainComponent to have reference and it depends on

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 18 of 30

some other components service So a new component (AddComponent) with aservice need to be created and map the MainComponent reference to the service ofAddComponent as highlighted in Figure 16

Figure 16 Wiring MainComponent reference to AddComponent service

bull The steps for creating AddComponent and service are similar toMainComponent

bull The MainComponent implementation should have reference definition asshown in Listing 3

Listing 3 Reference definition

AddInterface addInterface

Referencepublic void setAddReference(AddInterface addInterface)

thisaddInterface=addInterface

bull MainComponent reference and AddComponent service should be boundto SCA binding as shown in properties window of Figure 18 This is notmandatory by default if not chosen any bindings for a service orreference default SCA bindings are applied automatically

bull The AddComponent implementation class should be as shown in Listing4

Listing 4 AddComponent implementation

package comibmscasampleimport orgosoascaannotationsService

Service (AddInterfaceclass)public class AddInterfaceImpl implements AddInterface

public int add(int firstValue int secordValue) return firstValue+secordValue

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 19 of 30

Similarly SubstractComponent MultiplyComponent and DivisionComponent and itsservices can be created and wired to the MainComponents different referencesUpon creating all the above components the Calculator SCA composite diagramshould look as shown in Figure 17

Figure 17 Calculator SCA composite diagram

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 20 of 30

Create Contribution

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 21 of 30

Contribution can be created for the Calculator composite using RAD wizards asshown in Figure 18

Figure 18 Creating Contribution

Once the contribution is created it can be added to deploy on the local WebSphereApplication Server instance as shown in Figure 19 and Figure 20

Figure 19 AddingRemoving projects

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 22 of 30

Figure 20 Adding Calculator project

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 23 of 30

Note The contribution can also be exported as SCA archive file for deployment intoWebSphere Application Server external to the RAD

Servlet client using SCA Calculator application

This section describes how to use the Calculator SCA applicationMainComponenent service from a Servlet application

bull Create a Dynamic Web project from the RAD workspace

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 24 of 30

bull Make sure the WSDL can be located athttpserver-namehttp-portMainComponentCalculatorInterfacewsdl

Create the WSDL stub classes using following steps

1 Open File gt New gt Other and select Web service client project

2 Specifyhttpserver-namehttp-portMainComponentCalculatorInterfacewsdl inthe service definition

3 Specify the Develop client as highlighted in Figure 21 and click Nextbutton

Figure 21 Web service client

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 25 of 30

4 Specify the package comibmscastubs as shown in Figure 22 and clickon Finish

Figure 22 Specify stub classes package

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 26 of 30

The Servlet can use the code as highlighted in Listing 5 below

Listing 5 Web service stub APIs

import comibmscastubsCalculatorInterfaceimport comibmscastubsCalculatorInterfaceServiceCalculatorInterfaceService service = new CalculatorInterfaceService()CalculatorInterface ci = (CalculatorInterface) servicegetCalculatorInterfacePort()

int result = cicalculate(firstValue secondValue operation)

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 27 of 30

Working with supplied sample

This section describes the steps required to deploy the Calculator SCA sample anddeploying the SCA Servlet client application and working with it

bull Download and extract the downloadzip file located in the downloadsection

bull Run the following command to deploy the SCA application as BLA andalso deploying the Servlet client

bull Unix platformswsadminsh ndashf deploypy

bull Windows platformwsadminbat ndashf deploypy

bull To undeploy the samples run the following command

bull Unix platformswsadminsh ndashf undeploypy

bull Windows platformwsadminbat ndashf undeploypy

bull To run the sample application open the following URLhttpserver-namehttp-portSCAClient

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 28 of 30

Downloads

Description Name Size Downloadmethod

Sample downloads scripts for thisarticle

DoNotLeaveThisLinkzip 10KB HTTP

Information about download methods

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 29 of 30

Resources

bull Rational Application Developer Information Center

bull Education Assistant for WebSphere Application Server V70 Feature Pack forService Component Architecture

bull Exploring the WebSphere Application Server Feature Pack for SCA Part 1 Anoverview of the Service Component Architecture feature pack (Dec 2008) is anintroduction to open Service Component Architecture (SCA) conceptsobjectives of the technology and highlights of some key integration points

About the author

Lokanadham NallaLokanadham Nalla is a TXSeries Developer located in India SoftwareLabs Bangalore India with expertise in Java J2EE and SOAtechnologies

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 30 of 30

  • Table of Contents
  • Overview
  • Installation
  • Developing SCA applications using RAD
  • Servlet client using SCA Calculator application
  • Working with supplied sample
  • Downloads
  • Resources
  • About the author
Page 4: Developing service component architecture applications using rational application developer

bull Also ensure Feature Pack for Service Component Architecture isenabled under WebSphere Application Server section as highlighted infigure 2 below

Figure 2 Feature Pack for Service Component Architecture

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 4 of 30

Installing SCA Feature Pack

This section provides information on SCA Feature Pack installation if theWebSphere Application Server is installed external to RAD

To install the Service Component Architecture (SCA) Feature Pack you need tocomplete the instructions provided in the section Installing and uninstalling thefeature pack on distributed operating systems in the WebSphere Application ServerInformation Center

Developing SCA applications using RAD

This section describes the tasks required to develop a sample SCA calculatorapplication using RAD wizards

bull Create SCA Project

bull Create SCA Composite

bull Create SCA Component

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 5 of 30

bull Adding service or reference to a Component

bull Apply binding to a service or reference

bull Component implementation

bull Create Contribution

Creating a SCA project

This section describes how to create a new SCA project using RAD wizards FromRAD workspace open menu options File gt New gt Other Select SCA Project asshown in Figure 3

Figure 3 Create SCA Project

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 6 of 30

Specify project name as CalculatorProject as shown in Figure 4 below and makesure Implementation Types for SCA Components section Java checkbox isenabled

Figure 4 SCA Project Options

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 7 of 30

Click Next gt Finish buttons to create CalculatorProject

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 8 of 30

Create SCA Composite

Expand the CalculatorProject gt SCA Content from the Enterprise Explorer windowand right click on Composites select New gt SCA Composite as shown is Figure 5

Figure 5 Create SCA Composite

Specify Composite name as CalculatorComposite and Target namespace ashttpcalculator as shown in Figure 6 and click on Finish button

Figure 6 SCA Composite options

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 9 of 30

Create SCA Component

Expand CalculatorProject gt SCA Content gt Composites gt httpcalculator gt andright click on CalculatorComposite Select option New gt SCA Component as shownin Figure 7

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 10 of 30

Figure 7 Create SCA Component

Specify Component name as MainComponent as specified in Figure 8 and click onFinish button

Figure 8 SCA Component options

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 11 of 30

MainComponent image is created on the composite diagram as shown in Figure 9

Figure 9 MainComponent

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 12 of 30

Adding service or reference to a Component

Right click on the MainComponent image to create a service and a reference asshown in Figure 10 and Figure 11 Name the service as CalculatorInterface and thereference as addReference

Figure 10 Adding a service

Figure 11 Adding a reference

There are two approaches for SCA service implementation top-down and

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 13 of 30

bottom-up Top-down development is used when starting with an existing WSDLBottom-up development is used when starting from existing Java code The sampleuses bottom-up approach where service Interface type is set to Java

bull Create package comibmscasample under src folder of theCalculatorProject

bull Create a new Java interface as shown in Listing 1

Listing 1 Service Interface

package comibmscasample

import orgosoascaannotationsRemotable

Remotablepublic interface CalculatorInterface

int calculate(int firstValue int secondValue String operation)

bull Make sure you have Remotable annotation is added to the interface

bull Set the service Interface property tocomibmscasamplesCalculatorInterface as highlighted in Figure 12

Figure 12 Set service interface

Note If top-down approach is used select Interface type as WSDL and specify thelocation of the WSDL in Interface

Apply binding to a service or reference

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 14 of 30

The SCA Feature Pack supports following bindings

bull Web service

bull Atom

bull HTTP

bull EJB

bull JMS

bull SCA

Users can choose to apply these binding depending on the type of client they areusing If the client application is a web service client then web service binding canbe applied If the client application is EJB client EJB bindings can be applied

In the Calculator sample application the web service binding is used so that theclient Servlet application can use the generated WSDL file for communication withCalculator SCA application Follow the below steps for applying web service bindingto the CalculatorInterface service

bull Right click on the CalculatorInterface service select Show PropertiesView option from the menu panel which displays the properties windowas shown in bottom panel of Figure 13

bull Select Binding option from the left pane of the properties window

bull List of SCA Feature Pack supported bindings are displayed after clickingon Add button on the Bindings as shown in Figure 13

bull Select web service from the list of bindings and click OK Now the webservice client APIs can be used to invoke the SCA Calculator application

bull When the Calculator application is deployed into WebSphere ApplicationServer It generates a WSDL file and it can be located using followingURLhttpserver-namehttp-portMainComponentCalculatorInterfacewsdl

Figure 13 Service properties and bindings

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 15 of 30

Similarly bindings can also be applied for a reference

Component implementation

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 16 of 30

Right click on the MainComponent and select Regenerate implementation optionas shown in Figure 14

Figure 14 Generate Implementation

bull Choose Java from the list of Implementation Type in the next window

bull Click the Next button and observe the implementation class it is going tobe generated as highlighted in Figure 15

bull Click on the Finish button to generate the implementation classcomibmscasamplesCalculatorInterfaceImpl

Figure 15 Implementation class configuration

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 17 of 30

Listing 2 below shows the generated implementation class

Listing 2 Implementation class

package comibmscasample

import orgosoascaannotationsService

Service (CalculatorInterfaceclass)public class CalculatorInterfaceImpl implements CalculatorInterface

public int calculate(int firstValue int secondValue String operation) return 0

The created reference needs to be defined in the component implementation Inother words we mandated MainComponent to have reference and it depends on

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 18 of 30

some other components service So a new component (AddComponent) with aservice need to be created and map the MainComponent reference to the service ofAddComponent as highlighted in Figure 16

Figure 16 Wiring MainComponent reference to AddComponent service

bull The steps for creating AddComponent and service are similar toMainComponent

bull The MainComponent implementation should have reference definition asshown in Listing 3

Listing 3 Reference definition

AddInterface addInterface

Referencepublic void setAddReference(AddInterface addInterface)

thisaddInterface=addInterface

bull MainComponent reference and AddComponent service should be boundto SCA binding as shown in properties window of Figure 18 This is notmandatory by default if not chosen any bindings for a service orreference default SCA bindings are applied automatically

bull The AddComponent implementation class should be as shown in Listing4

Listing 4 AddComponent implementation

package comibmscasampleimport orgosoascaannotationsService

Service (AddInterfaceclass)public class AddInterfaceImpl implements AddInterface

public int add(int firstValue int secordValue) return firstValue+secordValue

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 19 of 30

Similarly SubstractComponent MultiplyComponent and DivisionComponent and itsservices can be created and wired to the MainComponents different referencesUpon creating all the above components the Calculator SCA composite diagramshould look as shown in Figure 17

Figure 17 Calculator SCA composite diagram

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 20 of 30

Create Contribution

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 21 of 30

Contribution can be created for the Calculator composite using RAD wizards asshown in Figure 18

Figure 18 Creating Contribution

Once the contribution is created it can be added to deploy on the local WebSphereApplication Server instance as shown in Figure 19 and Figure 20

Figure 19 AddingRemoving projects

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 22 of 30

Figure 20 Adding Calculator project

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 23 of 30

Note The contribution can also be exported as SCA archive file for deployment intoWebSphere Application Server external to the RAD

Servlet client using SCA Calculator application

This section describes how to use the Calculator SCA applicationMainComponenent service from a Servlet application

bull Create a Dynamic Web project from the RAD workspace

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 24 of 30

bull Make sure the WSDL can be located athttpserver-namehttp-portMainComponentCalculatorInterfacewsdl

Create the WSDL stub classes using following steps

1 Open File gt New gt Other and select Web service client project

2 Specifyhttpserver-namehttp-portMainComponentCalculatorInterfacewsdl inthe service definition

3 Specify the Develop client as highlighted in Figure 21 and click Nextbutton

Figure 21 Web service client

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 25 of 30

4 Specify the package comibmscastubs as shown in Figure 22 and clickon Finish

Figure 22 Specify stub classes package

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 26 of 30

The Servlet can use the code as highlighted in Listing 5 below

Listing 5 Web service stub APIs

import comibmscastubsCalculatorInterfaceimport comibmscastubsCalculatorInterfaceServiceCalculatorInterfaceService service = new CalculatorInterfaceService()CalculatorInterface ci = (CalculatorInterface) servicegetCalculatorInterfacePort()

int result = cicalculate(firstValue secondValue operation)

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 27 of 30

Working with supplied sample

This section describes the steps required to deploy the Calculator SCA sample anddeploying the SCA Servlet client application and working with it

bull Download and extract the downloadzip file located in the downloadsection

bull Run the following command to deploy the SCA application as BLA andalso deploying the Servlet client

bull Unix platformswsadminsh ndashf deploypy

bull Windows platformwsadminbat ndashf deploypy

bull To undeploy the samples run the following command

bull Unix platformswsadminsh ndashf undeploypy

bull Windows platformwsadminbat ndashf undeploypy

bull To run the sample application open the following URLhttpserver-namehttp-portSCAClient

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 28 of 30

Downloads

Description Name Size Downloadmethod

Sample downloads scripts for thisarticle

DoNotLeaveThisLinkzip 10KB HTTP

Information about download methods

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 29 of 30

Resources

bull Rational Application Developer Information Center

bull Education Assistant for WebSphere Application Server V70 Feature Pack forService Component Architecture

bull Exploring the WebSphere Application Server Feature Pack for SCA Part 1 Anoverview of the Service Component Architecture feature pack (Dec 2008) is anintroduction to open Service Component Architecture (SCA) conceptsobjectives of the technology and highlights of some key integration points

About the author

Lokanadham NallaLokanadham Nalla is a TXSeries Developer located in India SoftwareLabs Bangalore India with expertise in Java J2EE and SOAtechnologies

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 30 of 30

  • Table of Contents
  • Overview
  • Installation
  • Developing SCA applications using RAD
  • Servlet client using SCA Calculator application
  • Working with supplied sample
  • Downloads
  • Resources
  • About the author
Page 5: Developing service component architecture applications using rational application developer

Installing SCA Feature Pack

This section provides information on SCA Feature Pack installation if theWebSphere Application Server is installed external to RAD

To install the Service Component Architecture (SCA) Feature Pack you need tocomplete the instructions provided in the section Installing and uninstalling thefeature pack on distributed operating systems in the WebSphere Application ServerInformation Center

Developing SCA applications using RAD

This section describes the tasks required to develop a sample SCA calculatorapplication using RAD wizards

bull Create SCA Project

bull Create SCA Composite

bull Create SCA Component

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 5 of 30

bull Adding service or reference to a Component

bull Apply binding to a service or reference

bull Component implementation

bull Create Contribution

Creating a SCA project

This section describes how to create a new SCA project using RAD wizards FromRAD workspace open menu options File gt New gt Other Select SCA Project asshown in Figure 3

Figure 3 Create SCA Project

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 6 of 30

Specify project name as CalculatorProject as shown in Figure 4 below and makesure Implementation Types for SCA Components section Java checkbox isenabled

Figure 4 SCA Project Options

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 7 of 30

Click Next gt Finish buttons to create CalculatorProject

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 8 of 30

Create SCA Composite

Expand the CalculatorProject gt SCA Content from the Enterprise Explorer windowand right click on Composites select New gt SCA Composite as shown is Figure 5

Figure 5 Create SCA Composite

Specify Composite name as CalculatorComposite and Target namespace ashttpcalculator as shown in Figure 6 and click on Finish button

Figure 6 SCA Composite options

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 9 of 30

Create SCA Component

Expand CalculatorProject gt SCA Content gt Composites gt httpcalculator gt andright click on CalculatorComposite Select option New gt SCA Component as shownin Figure 7

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 10 of 30

Figure 7 Create SCA Component

Specify Component name as MainComponent as specified in Figure 8 and click onFinish button

Figure 8 SCA Component options

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 11 of 30

MainComponent image is created on the composite diagram as shown in Figure 9

Figure 9 MainComponent

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 12 of 30

Adding service or reference to a Component

Right click on the MainComponent image to create a service and a reference asshown in Figure 10 and Figure 11 Name the service as CalculatorInterface and thereference as addReference

Figure 10 Adding a service

Figure 11 Adding a reference

There are two approaches for SCA service implementation top-down and

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 13 of 30

bottom-up Top-down development is used when starting with an existing WSDLBottom-up development is used when starting from existing Java code The sampleuses bottom-up approach where service Interface type is set to Java

bull Create package comibmscasample under src folder of theCalculatorProject

bull Create a new Java interface as shown in Listing 1

Listing 1 Service Interface

package comibmscasample

import orgosoascaannotationsRemotable

Remotablepublic interface CalculatorInterface

int calculate(int firstValue int secondValue String operation)

bull Make sure you have Remotable annotation is added to the interface

bull Set the service Interface property tocomibmscasamplesCalculatorInterface as highlighted in Figure 12

Figure 12 Set service interface

Note If top-down approach is used select Interface type as WSDL and specify thelocation of the WSDL in Interface

Apply binding to a service or reference

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 14 of 30

The SCA Feature Pack supports following bindings

bull Web service

bull Atom

bull HTTP

bull EJB

bull JMS

bull SCA

Users can choose to apply these binding depending on the type of client they areusing If the client application is a web service client then web service binding canbe applied If the client application is EJB client EJB bindings can be applied

In the Calculator sample application the web service binding is used so that theclient Servlet application can use the generated WSDL file for communication withCalculator SCA application Follow the below steps for applying web service bindingto the CalculatorInterface service

bull Right click on the CalculatorInterface service select Show PropertiesView option from the menu panel which displays the properties windowas shown in bottom panel of Figure 13

bull Select Binding option from the left pane of the properties window

bull List of SCA Feature Pack supported bindings are displayed after clickingon Add button on the Bindings as shown in Figure 13

bull Select web service from the list of bindings and click OK Now the webservice client APIs can be used to invoke the SCA Calculator application

bull When the Calculator application is deployed into WebSphere ApplicationServer It generates a WSDL file and it can be located using followingURLhttpserver-namehttp-portMainComponentCalculatorInterfacewsdl

Figure 13 Service properties and bindings

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 15 of 30

Similarly bindings can also be applied for a reference

Component implementation

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 16 of 30

Right click on the MainComponent and select Regenerate implementation optionas shown in Figure 14

Figure 14 Generate Implementation

bull Choose Java from the list of Implementation Type in the next window

bull Click the Next button and observe the implementation class it is going tobe generated as highlighted in Figure 15

bull Click on the Finish button to generate the implementation classcomibmscasamplesCalculatorInterfaceImpl

Figure 15 Implementation class configuration

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 17 of 30

Listing 2 below shows the generated implementation class

Listing 2 Implementation class

package comibmscasample

import orgosoascaannotationsService

Service (CalculatorInterfaceclass)public class CalculatorInterfaceImpl implements CalculatorInterface

public int calculate(int firstValue int secondValue String operation) return 0

The created reference needs to be defined in the component implementation Inother words we mandated MainComponent to have reference and it depends on

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 18 of 30

some other components service So a new component (AddComponent) with aservice need to be created and map the MainComponent reference to the service ofAddComponent as highlighted in Figure 16

Figure 16 Wiring MainComponent reference to AddComponent service

bull The steps for creating AddComponent and service are similar toMainComponent

bull The MainComponent implementation should have reference definition asshown in Listing 3

Listing 3 Reference definition

AddInterface addInterface

Referencepublic void setAddReference(AddInterface addInterface)

thisaddInterface=addInterface

bull MainComponent reference and AddComponent service should be boundto SCA binding as shown in properties window of Figure 18 This is notmandatory by default if not chosen any bindings for a service orreference default SCA bindings are applied automatically

bull The AddComponent implementation class should be as shown in Listing4

Listing 4 AddComponent implementation

package comibmscasampleimport orgosoascaannotationsService

Service (AddInterfaceclass)public class AddInterfaceImpl implements AddInterface

public int add(int firstValue int secordValue) return firstValue+secordValue

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 19 of 30

Similarly SubstractComponent MultiplyComponent and DivisionComponent and itsservices can be created and wired to the MainComponents different referencesUpon creating all the above components the Calculator SCA composite diagramshould look as shown in Figure 17

Figure 17 Calculator SCA composite diagram

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 20 of 30

Create Contribution

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 21 of 30

Contribution can be created for the Calculator composite using RAD wizards asshown in Figure 18

Figure 18 Creating Contribution

Once the contribution is created it can be added to deploy on the local WebSphereApplication Server instance as shown in Figure 19 and Figure 20

Figure 19 AddingRemoving projects

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 22 of 30

Figure 20 Adding Calculator project

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 23 of 30

Note The contribution can also be exported as SCA archive file for deployment intoWebSphere Application Server external to the RAD

Servlet client using SCA Calculator application

This section describes how to use the Calculator SCA applicationMainComponenent service from a Servlet application

bull Create a Dynamic Web project from the RAD workspace

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 24 of 30

bull Make sure the WSDL can be located athttpserver-namehttp-portMainComponentCalculatorInterfacewsdl

Create the WSDL stub classes using following steps

1 Open File gt New gt Other and select Web service client project

2 Specifyhttpserver-namehttp-portMainComponentCalculatorInterfacewsdl inthe service definition

3 Specify the Develop client as highlighted in Figure 21 and click Nextbutton

Figure 21 Web service client

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 25 of 30

4 Specify the package comibmscastubs as shown in Figure 22 and clickon Finish

Figure 22 Specify stub classes package

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 26 of 30

The Servlet can use the code as highlighted in Listing 5 below

Listing 5 Web service stub APIs

import comibmscastubsCalculatorInterfaceimport comibmscastubsCalculatorInterfaceServiceCalculatorInterfaceService service = new CalculatorInterfaceService()CalculatorInterface ci = (CalculatorInterface) servicegetCalculatorInterfacePort()

int result = cicalculate(firstValue secondValue operation)

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 27 of 30

Working with supplied sample

This section describes the steps required to deploy the Calculator SCA sample anddeploying the SCA Servlet client application and working with it

bull Download and extract the downloadzip file located in the downloadsection

bull Run the following command to deploy the SCA application as BLA andalso deploying the Servlet client

bull Unix platformswsadminsh ndashf deploypy

bull Windows platformwsadminbat ndashf deploypy

bull To undeploy the samples run the following command

bull Unix platformswsadminsh ndashf undeploypy

bull Windows platformwsadminbat ndashf undeploypy

bull To run the sample application open the following URLhttpserver-namehttp-portSCAClient

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 28 of 30

Downloads

Description Name Size Downloadmethod

Sample downloads scripts for thisarticle

DoNotLeaveThisLinkzip 10KB HTTP

Information about download methods

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 29 of 30

Resources

bull Rational Application Developer Information Center

bull Education Assistant for WebSphere Application Server V70 Feature Pack forService Component Architecture

bull Exploring the WebSphere Application Server Feature Pack for SCA Part 1 Anoverview of the Service Component Architecture feature pack (Dec 2008) is anintroduction to open Service Component Architecture (SCA) conceptsobjectives of the technology and highlights of some key integration points

About the author

Lokanadham NallaLokanadham Nalla is a TXSeries Developer located in India SoftwareLabs Bangalore India with expertise in Java J2EE and SOAtechnologies

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 30 of 30

  • Table of Contents
  • Overview
  • Installation
  • Developing SCA applications using RAD
  • Servlet client using SCA Calculator application
  • Working with supplied sample
  • Downloads
  • Resources
  • About the author
Page 6: Developing service component architecture applications using rational application developer

bull Adding service or reference to a Component

bull Apply binding to a service or reference

bull Component implementation

bull Create Contribution

Creating a SCA project

This section describes how to create a new SCA project using RAD wizards FromRAD workspace open menu options File gt New gt Other Select SCA Project asshown in Figure 3

Figure 3 Create SCA Project

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 6 of 30

Specify project name as CalculatorProject as shown in Figure 4 below and makesure Implementation Types for SCA Components section Java checkbox isenabled

Figure 4 SCA Project Options

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 7 of 30

Click Next gt Finish buttons to create CalculatorProject

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 8 of 30

Create SCA Composite

Expand the CalculatorProject gt SCA Content from the Enterprise Explorer windowand right click on Composites select New gt SCA Composite as shown is Figure 5

Figure 5 Create SCA Composite

Specify Composite name as CalculatorComposite and Target namespace ashttpcalculator as shown in Figure 6 and click on Finish button

Figure 6 SCA Composite options

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 9 of 30

Create SCA Component

Expand CalculatorProject gt SCA Content gt Composites gt httpcalculator gt andright click on CalculatorComposite Select option New gt SCA Component as shownin Figure 7

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 10 of 30

Figure 7 Create SCA Component

Specify Component name as MainComponent as specified in Figure 8 and click onFinish button

Figure 8 SCA Component options

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 11 of 30

MainComponent image is created on the composite diagram as shown in Figure 9

Figure 9 MainComponent

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 12 of 30

Adding service or reference to a Component

Right click on the MainComponent image to create a service and a reference asshown in Figure 10 and Figure 11 Name the service as CalculatorInterface and thereference as addReference

Figure 10 Adding a service

Figure 11 Adding a reference

There are two approaches for SCA service implementation top-down and

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 13 of 30

bottom-up Top-down development is used when starting with an existing WSDLBottom-up development is used when starting from existing Java code The sampleuses bottom-up approach where service Interface type is set to Java

bull Create package comibmscasample under src folder of theCalculatorProject

bull Create a new Java interface as shown in Listing 1

Listing 1 Service Interface

package comibmscasample

import orgosoascaannotationsRemotable

Remotablepublic interface CalculatorInterface

int calculate(int firstValue int secondValue String operation)

bull Make sure you have Remotable annotation is added to the interface

bull Set the service Interface property tocomibmscasamplesCalculatorInterface as highlighted in Figure 12

Figure 12 Set service interface

Note If top-down approach is used select Interface type as WSDL and specify thelocation of the WSDL in Interface

Apply binding to a service or reference

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 14 of 30

The SCA Feature Pack supports following bindings

bull Web service

bull Atom

bull HTTP

bull EJB

bull JMS

bull SCA

Users can choose to apply these binding depending on the type of client they areusing If the client application is a web service client then web service binding canbe applied If the client application is EJB client EJB bindings can be applied

In the Calculator sample application the web service binding is used so that theclient Servlet application can use the generated WSDL file for communication withCalculator SCA application Follow the below steps for applying web service bindingto the CalculatorInterface service

bull Right click on the CalculatorInterface service select Show PropertiesView option from the menu panel which displays the properties windowas shown in bottom panel of Figure 13

bull Select Binding option from the left pane of the properties window

bull List of SCA Feature Pack supported bindings are displayed after clickingon Add button on the Bindings as shown in Figure 13

bull Select web service from the list of bindings and click OK Now the webservice client APIs can be used to invoke the SCA Calculator application

bull When the Calculator application is deployed into WebSphere ApplicationServer It generates a WSDL file and it can be located using followingURLhttpserver-namehttp-portMainComponentCalculatorInterfacewsdl

Figure 13 Service properties and bindings

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 15 of 30

Similarly bindings can also be applied for a reference

Component implementation

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 16 of 30

Right click on the MainComponent and select Regenerate implementation optionas shown in Figure 14

Figure 14 Generate Implementation

bull Choose Java from the list of Implementation Type in the next window

bull Click the Next button and observe the implementation class it is going tobe generated as highlighted in Figure 15

bull Click on the Finish button to generate the implementation classcomibmscasamplesCalculatorInterfaceImpl

Figure 15 Implementation class configuration

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 17 of 30

Listing 2 below shows the generated implementation class

Listing 2 Implementation class

package comibmscasample

import orgosoascaannotationsService

Service (CalculatorInterfaceclass)public class CalculatorInterfaceImpl implements CalculatorInterface

public int calculate(int firstValue int secondValue String operation) return 0

The created reference needs to be defined in the component implementation Inother words we mandated MainComponent to have reference and it depends on

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 18 of 30

some other components service So a new component (AddComponent) with aservice need to be created and map the MainComponent reference to the service ofAddComponent as highlighted in Figure 16

Figure 16 Wiring MainComponent reference to AddComponent service

bull The steps for creating AddComponent and service are similar toMainComponent

bull The MainComponent implementation should have reference definition asshown in Listing 3

Listing 3 Reference definition

AddInterface addInterface

Referencepublic void setAddReference(AddInterface addInterface)

thisaddInterface=addInterface

bull MainComponent reference and AddComponent service should be boundto SCA binding as shown in properties window of Figure 18 This is notmandatory by default if not chosen any bindings for a service orreference default SCA bindings are applied automatically

bull The AddComponent implementation class should be as shown in Listing4

Listing 4 AddComponent implementation

package comibmscasampleimport orgosoascaannotationsService

Service (AddInterfaceclass)public class AddInterfaceImpl implements AddInterface

public int add(int firstValue int secordValue) return firstValue+secordValue

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 19 of 30

Similarly SubstractComponent MultiplyComponent and DivisionComponent and itsservices can be created and wired to the MainComponents different referencesUpon creating all the above components the Calculator SCA composite diagramshould look as shown in Figure 17

Figure 17 Calculator SCA composite diagram

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 20 of 30

Create Contribution

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 21 of 30

Contribution can be created for the Calculator composite using RAD wizards asshown in Figure 18

Figure 18 Creating Contribution

Once the contribution is created it can be added to deploy on the local WebSphereApplication Server instance as shown in Figure 19 and Figure 20

Figure 19 AddingRemoving projects

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 22 of 30

Figure 20 Adding Calculator project

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 23 of 30

Note The contribution can also be exported as SCA archive file for deployment intoWebSphere Application Server external to the RAD

Servlet client using SCA Calculator application

This section describes how to use the Calculator SCA applicationMainComponenent service from a Servlet application

bull Create a Dynamic Web project from the RAD workspace

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 24 of 30

bull Make sure the WSDL can be located athttpserver-namehttp-portMainComponentCalculatorInterfacewsdl

Create the WSDL stub classes using following steps

1 Open File gt New gt Other and select Web service client project

2 Specifyhttpserver-namehttp-portMainComponentCalculatorInterfacewsdl inthe service definition

3 Specify the Develop client as highlighted in Figure 21 and click Nextbutton

Figure 21 Web service client

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 25 of 30

4 Specify the package comibmscastubs as shown in Figure 22 and clickon Finish

Figure 22 Specify stub classes package

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 26 of 30

The Servlet can use the code as highlighted in Listing 5 below

Listing 5 Web service stub APIs

import comibmscastubsCalculatorInterfaceimport comibmscastubsCalculatorInterfaceServiceCalculatorInterfaceService service = new CalculatorInterfaceService()CalculatorInterface ci = (CalculatorInterface) servicegetCalculatorInterfacePort()

int result = cicalculate(firstValue secondValue operation)

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 27 of 30

Working with supplied sample

This section describes the steps required to deploy the Calculator SCA sample anddeploying the SCA Servlet client application and working with it

bull Download and extract the downloadzip file located in the downloadsection

bull Run the following command to deploy the SCA application as BLA andalso deploying the Servlet client

bull Unix platformswsadminsh ndashf deploypy

bull Windows platformwsadminbat ndashf deploypy

bull To undeploy the samples run the following command

bull Unix platformswsadminsh ndashf undeploypy

bull Windows platformwsadminbat ndashf undeploypy

bull To run the sample application open the following URLhttpserver-namehttp-portSCAClient

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 28 of 30

Downloads

Description Name Size Downloadmethod

Sample downloads scripts for thisarticle

DoNotLeaveThisLinkzip 10KB HTTP

Information about download methods

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 29 of 30

Resources

bull Rational Application Developer Information Center

bull Education Assistant for WebSphere Application Server V70 Feature Pack forService Component Architecture

bull Exploring the WebSphere Application Server Feature Pack for SCA Part 1 Anoverview of the Service Component Architecture feature pack (Dec 2008) is anintroduction to open Service Component Architecture (SCA) conceptsobjectives of the technology and highlights of some key integration points

About the author

Lokanadham NallaLokanadham Nalla is a TXSeries Developer located in India SoftwareLabs Bangalore India with expertise in Java J2EE and SOAtechnologies

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 30 of 30

  • Table of Contents
  • Overview
  • Installation
  • Developing SCA applications using RAD
  • Servlet client using SCA Calculator application
  • Working with supplied sample
  • Downloads
  • Resources
  • About the author
Page 7: Developing service component architecture applications using rational application developer

Specify project name as CalculatorProject as shown in Figure 4 below and makesure Implementation Types for SCA Components section Java checkbox isenabled

Figure 4 SCA Project Options

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 7 of 30

Click Next gt Finish buttons to create CalculatorProject

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 8 of 30

Create SCA Composite

Expand the CalculatorProject gt SCA Content from the Enterprise Explorer windowand right click on Composites select New gt SCA Composite as shown is Figure 5

Figure 5 Create SCA Composite

Specify Composite name as CalculatorComposite and Target namespace ashttpcalculator as shown in Figure 6 and click on Finish button

Figure 6 SCA Composite options

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 9 of 30

Create SCA Component

Expand CalculatorProject gt SCA Content gt Composites gt httpcalculator gt andright click on CalculatorComposite Select option New gt SCA Component as shownin Figure 7

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 10 of 30

Figure 7 Create SCA Component

Specify Component name as MainComponent as specified in Figure 8 and click onFinish button

Figure 8 SCA Component options

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 11 of 30

MainComponent image is created on the composite diagram as shown in Figure 9

Figure 9 MainComponent

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 12 of 30

Adding service or reference to a Component

Right click on the MainComponent image to create a service and a reference asshown in Figure 10 and Figure 11 Name the service as CalculatorInterface and thereference as addReference

Figure 10 Adding a service

Figure 11 Adding a reference

There are two approaches for SCA service implementation top-down and

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 13 of 30

bottom-up Top-down development is used when starting with an existing WSDLBottom-up development is used when starting from existing Java code The sampleuses bottom-up approach where service Interface type is set to Java

bull Create package comibmscasample under src folder of theCalculatorProject

bull Create a new Java interface as shown in Listing 1

Listing 1 Service Interface

package comibmscasample

import orgosoascaannotationsRemotable

Remotablepublic interface CalculatorInterface

int calculate(int firstValue int secondValue String operation)

bull Make sure you have Remotable annotation is added to the interface

bull Set the service Interface property tocomibmscasamplesCalculatorInterface as highlighted in Figure 12

Figure 12 Set service interface

Note If top-down approach is used select Interface type as WSDL and specify thelocation of the WSDL in Interface

Apply binding to a service or reference

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 14 of 30

The SCA Feature Pack supports following bindings

bull Web service

bull Atom

bull HTTP

bull EJB

bull JMS

bull SCA

Users can choose to apply these binding depending on the type of client they areusing If the client application is a web service client then web service binding canbe applied If the client application is EJB client EJB bindings can be applied

In the Calculator sample application the web service binding is used so that theclient Servlet application can use the generated WSDL file for communication withCalculator SCA application Follow the below steps for applying web service bindingto the CalculatorInterface service

bull Right click on the CalculatorInterface service select Show PropertiesView option from the menu panel which displays the properties windowas shown in bottom panel of Figure 13

bull Select Binding option from the left pane of the properties window

bull List of SCA Feature Pack supported bindings are displayed after clickingon Add button on the Bindings as shown in Figure 13

bull Select web service from the list of bindings and click OK Now the webservice client APIs can be used to invoke the SCA Calculator application

bull When the Calculator application is deployed into WebSphere ApplicationServer It generates a WSDL file and it can be located using followingURLhttpserver-namehttp-portMainComponentCalculatorInterfacewsdl

Figure 13 Service properties and bindings

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 15 of 30

Similarly bindings can also be applied for a reference

Component implementation

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 16 of 30

Right click on the MainComponent and select Regenerate implementation optionas shown in Figure 14

Figure 14 Generate Implementation

bull Choose Java from the list of Implementation Type in the next window

bull Click the Next button and observe the implementation class it is going tobe generated as highlighted in Figure 15

bull Click on the Finish button to generate the implementation classcomibmscasamplesCalculatorInterfaceImpl

Figure 15 Implementation class configuration

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 17 of 30

Listing 2 below shows the generated implementation class

Listing 2 Implementation class

package comibmscasample

import orgosoascaannotationsService

Service (CalculatorInterfaceclass)public class CalculatorInterfaceImpl implements CalculatorInterface

public int calculate(int firstValue int secondValue String operation) return 0

The created reference needs to be defined in the component implementation Inother words we mandated MainComponent to have reference and it depends on

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 18 of 30

some other components service So a new component (AddComponent) with aservice need to be created and map the MainComponent reference to the service ofAddComponent as highlighted in Figure 16

Figure 16 Wiring MainComponent reference to AddComponent service

bull The steps for creating AddComponent and service are similar toMainComponent

bull The MainComponent implementation should have reference definition asshown in Listing 3

Listing 3 Reference definition

AddInterface addInterface

Referencepublic void setAddReference(AddInterface addInterface)

thisaddInterface=addInterface

bull MainComponent reference and AddComponent service should be boundto SCA binding as shown in properties window of Figure 18 This is notmandatory by default if not chosen any bindings for a service orreference default SCA bindings are applied automatically

bull The AddComponent implementation class should be as shown in Listing4

Listing 4 AddComponent implementation

package comibmscasampleimport orgosoascaannotationsService

Service (AddInterfaceclass)public class AddInterfaceImpl implements AddInterface

public int add(int firstValue int secordValue) return firstValue+secordValue

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 19 of 30

Similarly SubstractComponent MultiplyComponent and DivisionComponent and itsservices can be created and wired to the MainComponents different referencesUpon creating all the above components the Calculator SCA composite diagramshould look as shown in Figure 17

Figure 17 Calculator SCA composite diagram

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 20 of 30

Create Contribution

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 21 of 30

Contribution can be created for the Calculator composite using RAD wizards asshown in Figure 18

Figure 18 Creating Contribution

Once the contribution is created it can be added to deploy on the local WebSphereApplication Server instance as shown in Figure 19 and Figure 20

Figure 19 AddingRemoving projects

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 22 of 30

Figure 20 Adding Calculator project

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 23 of 30

Note The contribution can also be exported as SCA archive file for deployment intoWebSphere Application Server external to the RAD

Servlet client using SCA Calculator application

This section describes how to use the Calculator SCA applicationMainComponenent service from a Servlet application

bull Create a Dynamic Web project from the RAD workspace

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 24 of 30

bull Make sure the WSDL can be located athttpserver-namehttp-portMainComponentCalculatorInterfacewsdl

Create the WSDL stub classes using following steps

1 Open File gt New gt Other and select Web service client project

2 Specifyhttpserver-namehttp-portMainComponentCalculatorInterfacewsdl inthe service definition

3 Specify the Develop client as highlighted in Figure 21 and click Nextbutton

Figure 21 Web service client

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 25 of 30

4 Specify the package comibmscastubs as shown in Figure 22 and clickon Finish

Figure 22 Specify stub classes package

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 26 of 30

The Servlet can use the code as highlighted in Listing 5 below

Listing 5 Web service stub APIs

import comibmscastubsCalculatorInterfaceimport comibmscastubsCalculatorInterfaceServiceCalculatorInterfaceService service = new CalculatorInterfaceService()CalculatorInterface ci = (CalculatorInterface) servicegetCalculatorInterfacePort()

int result = cicalculate(firstValue secondValue operation)

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 27 of 30

Working with supplied sample

This section describes the steps required to deploy the Calculator SCA sample anddeploying the SCA Servlet client application and working with it

bull Download and extract the downloadzip file located in the downloadsection

bull Run the following command to deploy the SCA application as BLA andalso deploying the Servlet client

bull Unix platformswsadminsh ndashf deploypy

bull Windows platformwsadminbat ndashf deploypy

bull To undeploy the samples run the following command

bull Unix platformswsadminsh ndashf undeploypy

bull Windows platformwsadminbat ndashf undeploypy

bull To run the sample application open the following URLhttpserver-namehttp-portSCAClient

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 28 of 30

Downloads

Description Name Size Downloadmethod

Sample downloads scripts for thisarticle

DoNotLeaveThisLinkzip 10KB HTTP

Information about download methods

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 29 of 30

Resources

bull Rational Application Developer Information Center

bull Education Assistant for WebSphere Application Server V70 Feature Pack forService Component Architecture

bull Exploring the WebSphere Application Server Feature Pack for SCA Part 1 Anoverview of the Service Component Architecture feature pack (Dec 2008) is anintroduction to open Service Component Architecture (SCA) conceptsobjectives of the technology and highlights of some key integration points

About the author

Lokanadham NallaLokanadham Nalla is a TXSeries Developer located in India SoftwareLabs Bangalore India with expertise in Java J2EE and SOAtechnologies

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 30 of 30

  • Table of Contents
  • Overview
  • Installation
  • Developing SCA applications using RAD
  • Servlet client using SCA Calculator application
  • Working with supplied sample
  • Downloads
  • Resources
  • About the author
Page 8: Developing service component architecture applications using rational application developer

Click Next gt Finish buttons to create CalculatorProject

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 8 of 30

Create SCA Composite

Expand the CalculatorProject gt SCA Content from the Enterprise Explorer windowand right click on Composites select New gt SCA Composite as shown is Figure 5

Figure 5 Create SCA Composite

Specify Composite name as CalculatorComposite and Target namespace ashttpcalculator as shown in Figure 6 and click on Finish button

Figure 6 SCA Composite options

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 9 of 30

Create SCA Component

Expand CalculatorProject gt SCA Content gt Composites gt httpcalculator gt andright click on CalculatorComposite Select option New gt SCA Component as shownin Figure 7

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 10 of 30

Figure 7 Create SCA Component

Specify Component name as MainComponent as specified in Figure 8 and click onFinish button

Figure 8 SCA Component options

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 11 of 30

MainComponent image is created on the composite diagram as shown in Figure 9

Figure 9 MainComponent

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 12 of 30

Adding service or reference to a Component

Right click on the MainComponent image to create a service and a reference asshown in Figure 10 and Figure 11 Name the service as CalculatorInterface and thereference as addReference

Figure 10 Adding a service

Figure 11 Adding a reference

There are two approaches for SCA service implementation top-down and

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 13 of 30

bottom-up Top-down development is used when starting with an existing WSDLBottom-up development is used when starting from existing Java code The sampleuses bottom-up approach where service Interface type is set to Java

bull Create package comibmscasample under src folder of theCalculatorProject

bull Create a new Java interface as shown in Listing 1

Listing 1 Service Interface

package comibmscasample

import orgosoascaannotationsRemotable

Remotablepublic interface CalculatorInterface

int calculate(int firstValue int secondValue String operation)

bull Make sure you have Remotable annotation is added to the interface

bull Set the service Interface property tocomibmscasamplesCalculatorInterface as highlighted in Figure 12

Figure 12 Set service interface

Note If top-down approach is used select Interface type as WSDL and specify thelocation of the WSDL in Interface

Apply binding to a service or reference

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 14 of 30

The SCA Feature Pack supports following bindings

bull Web service

bull Atom

bull HTTP

bull EJB

bull JMS

bull SCA

Users can choose to apply these binding depending on the type of client they areusing If the client application is a web service client then web service binding canbe applied If the client application is EJB client EJB bindings can be applied

In the Calculator sample application the web service binding is used so that theclient Servlet application can use the generated WSDL file for communication withCalculator SCA application Follow the below steps for applying web service bindingto the CalculatorInterface service

bull Right click on the CalculatorInterface service select Show PropertiesView option from the menu panel which displays the properties windowas shown in bottom panel of Figure 13

bull Select Binding option from the left pane of the properties window

bull List of SCA Feature Pack supported bindings are displayed after clickingon Add button on the Bindings as shown in Figure 13

bull Select web service from the list of bindings and click OK Now the webservice client APIs can be used to invoke the SCA Calculator application

bull When the Calculator application is deployed into WebSphere ApplicationServer It generates a WSDL file and it can be located using followingURLhttpserver-namehttp-portMainComponentCalculatorInterfacewsdl

Figure 13 Service properties and bindings

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 15 of 30

Similarly bindings can also be applied for a reference

Component implementation

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 16 of 30

Right click on the MainComponent and select Regenerate implementation optionas shown in Figure 14

Figure 14 Generate Implementation

bull Choose Java from the list of Implementation Type in the next window

bull Click the Next button and observe the implementation class it is going tobe generated as highlighted in Figure 15

bull Click on the Finish button to generate the implementation classcomibmscasamplesCalculatorInterfaceImpl

Figure 15 Implementation class configuration

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 17 of 30

Listing 2 below shows the generated implementation class

Listing 2 Implementation class

package comibmscasample

import orgosoascaannotationsService

Service (CalculatorInterfaceclass)public class CalculatorInterfaceImpl implements CalculatorInterface

public int calculate(int firstValue int secondValue String operation) return 0

The created reference needs to be defined in the component implementation Inother words we mandated MainComponent to have reference and it depends on

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 18 of 30

some other components service So a new component (AddComponent) with aservice need to be created and map the MainComponent reference to the service ofAddComponent as highlighted in Figure 16

Figure 16 Wiring MainComponent reference to AddComponent service

bull The steps for creating AddComponent and service are similar toMainComponent

bull The MainComponent implementation should have reference definition asshown in Listing 3

Listing 3 Reference definition

AddInterface addInterface

Referencepublic void setAddReference(AddInterface addInterface)

thisaddInterface=addInterface

bull MainComponent reference and AddComponent service should be boundto SCA binding as shown in properties window of Figure 18 This is notmandatory by default if not chosen any bindings for a service orreference default SCA bindings are applied automatically

bull The AddComponent implementation class should be as shown in Listing4

Listing 4 AddComponent implementation

package comibmscasampleimport orgosoascaannotationsService

Service (AddInterfaceclass)public class AddInterfaceImpl implements AddInterface

public int add(int firstValue int secordValue) return firstValue+secordValue

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 19 of 30

Similarly SubstractComponent MultiplyComponent and DivisionComponent and itsservices can be created and wired to the MainComponents different referencesUpon creating all the above components the Calculator SCA composite diagramshould look as shown in Figure 17

Figure 17 Calculator SCA composite diagram

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 20 of 30

Create Contribution

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 21 of 30

Contribution can be created for the Calculator composite using RAD wizards asshown in Figure 18

Figure 18 Creating Contribution

Once the contribution is created it can be added to deploy on the local WebSphereApplication Server instance as shown in Figure 19 and Figure 20

Figure 19 AddingRemoving projects

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 22 of 30

Figure 20 Adding Calculator project

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 23 of 30

Note The contribution can also be exported as SCA archive file for deployment intoWebSphere Application Server external to the RAD

Servlet client using SCA Calculator application

This section describes how to use the Calculator SCA applicationMainComponenent service from a Servlet application

bull Create a Dynamic Web project from the RAD workspace

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 24 of 30

bull Make sure the WSDL can be located athttpserver-namehttp-portMainComponentCalculatorInterfacewsdl

Create the WSDL stub classes using following steps

1 Open File gt New gt Other and select Web service client project

2 Specifyhttpserver-namehttp-portMainComponentCalculatorInterfacewsdl inthe service definition

3 Specify the Develop client as highlighted in Figure 21 and click Nextbutton

Figure 21 Web service client

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 25 of 30

4 Specify the package comibmscastubs as shown in Figure 22 and clickon Finish

Figure 22 Specify stub classes package

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 26 of 30

The Servlet can use the code as highlighted in Listing 5 below

Listing 5 Web service stub APIs

import comibmscastubsCalculatorInterfaceimport comibmscastubsCalculatorInterfaceServiceCalculatorInterfaceService service = new CalculatorInterfaceService()CalculatorInterface ci = (CalculatorInterface) servicegetCalculatorInterfacePort()

int result = cicalculate(firstValue secondValue operation)

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 27 of 30

Working with supplied sample

This section describes the steps required to deploy the Calculator SCA sample anddeploying the SCA Servlet client application and working with it

bull Download and extract the downloadzip file located in the downloadsection

bull Run the following command to deploy the SCA application as BLA andalso deploying the Servlet client

bull Unix platformswsadminsh ndashf deploypy

bull Windows platformwsadminbat ndashf deploypy

bull To undeploy the samples run the following command

bull Unix platformswsadminsh ndashf undeploypy

bull Windows platformwsadminbat ndashf undeploypy

bull To run the sample application open the following URLhttpserver-namehttp-portSCAClient

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 28 of 30

Downloads

Description Name Size Downloadmethod

Sample downloads scripts for thisarticle

DoNotLeaveThisLinkzip 10KB HTTP

Information about download methods

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 29 of 30

Resources

bull Rational Application Developer Information Center

bull Education Assistant for WebSphere Application Server V70 Feature Pack forService Component Architecture

bull Exploring the WebSphere Application Server Feature Pack for SCA Part 1 Anoverview of the Service Component Architecture feature pack (Dec 2008) is anintroduction to open Service Component Architecture (SCA) conceptsobjectives of the technology and highlights of some key integration points

About the author

Lokanadham NallaLokanadham Nalla is a TXSeries Developer located in India SoftwareLabs Bangalore India with expertise in Java J2EE and SOAtechnologies

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 30 of 30

  • Table of Contents
  • Overview
  • Installation
  • Developing SCA applications using RAD
  • Servlet client using SCA Calculator application
  • Working with supplied sample
  • Downloads
  • Resources
  • About the author
Page 9: Developing service component architecture applications using rational application developer

Create SCA Composite

Expand the CalculatorProject gt SCA Content from the Enterprise Explorer windowand right click on Composites select New gt SCA Composite as shown is Figure 5

Figure 5 Create SCA Composite

Specify Composite name as CalculatorComposite and Target namespace ashttpcalculator as shown in Figure 6 and click on Finish button

Figure 6 SCA Composite options

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 9 of 30

Create SCA Component

Expand CalculatorProject gt SCA Content gt Composites gt httpcalculator gt andright click on CalculatorComposite Select option New gt SCA Component as shownin Figure 7

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 10 of 30

Figure 7 Create SCA Component

Specify Component name as MainComponent as specified in Figure 8 and click onFinish button

Figure 8 SCA Component options

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 11 of 30

MainComponent image is created on the composite diagram as shown in Figure 9

Figure 9 MainComponent

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 12 of 30

Adding service or reference to a Component

Right click on the MainComponent image to create a service and a reference asshown in Figure 10 and Figure 11 Name the service as CalculatorInterface and thereference as addReference

Figure 10 Adding a service

Figure 11 Adding a reference

There are two approaches for SCA service implementation top-down and

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 13 of 30

bottom-up Top-down development is used when starting with an existing WSDLBottom-up development is used when starting from existing Java code The sampleuses bottom-up approach where service Interface type is set to Java

bull Create package comibmscasample under src folder of theCalculatorProject

bull Create a new Java interface as shown in Listing 1

Listing 1 Service Interface

package comibmscasample

import orgosoascaannotationsRemotable

Remotablepublic interface CalculatorInterface

int calculate(int firstValue int secondValue String operation)

bull Make sure you have Remotable annotation is added to the interface

bull Set the service Interface property tocomibmscasamplesCalculatorInterface as highlighted in Figure 12

Figure 12 Set service interface

Note If top-down approach is used select Interface type as WSDL and specify thelocation of the WSDL in Interface

Apply binding to a service or reference

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 14 of 30

The SCA Feature Pack supports following bindings

bull Web service

bull Atom

bull HTTP

bull EJB

bull JMS

bull SCA

Users can choose to apply these binding depending on the type of client they areusing If the client application is a web service client then web service binding canbe applied If the client application is EJB client EJB bindings can be applied

In the Calculator sample application the web service binding is used so that theclient Servlet application can use the generated WSDL file for communication withCalculator SCA application Follow the below steps for applying web service bindingto the CalculatorInterface service

bull Right click on the CalculatorInterface service select Show PropertiesView option from the menu panel which displays the properties windowas shown in bottom panel of Figure 13

bull Select Binding option from the left pane of the properties window

bull List of SCA Feature Pack supported bindings are displayed after clickingon Add button on the Bindings as shown in Figure 13

bull Select web service from the list of bindings and click OK Now the webservice client APIs can be used to invoke the SCA Calculator application

bull When the Calculator application is deployed into WebSphere ApplicationServer It generates a WSDL file and it can be located using followingURLhttpserver-namehttp-portMainComponentCalculatorInterfacewsdl

Figure 13 Service properties and bindings

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 15 of 30

Similarly bindings can also be applied for a reference

Component implementation

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 16 of 30

Right click on the MainComponent and select Regenerate implementation optionas shown in Figure 14

Figure 14 Generate Implementation

bull Choose Java from the list of Implementation Type in the next window

bull Click the Next button and observe the implementation class it is going tobe generated as highlighted in Figure 15

bull Click on the Finish button to generate the implementation classcomibmscasamplesCalculatorInterfaceImpl

Figure 15 Implementation class configuration

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 17 of 30

Listing 2 below shows the generated implementation class

Listing 2 Implementation class

package comibmscasample

import orgosoascaannotationsService

Service (CalculatorInterfaceclass)public class CalculatorInterfaceImpl implements CalculatorInterface

public int calculate(int firstValue int secondValue String operation) return 0

The created reference needs to be defined in the component implementation Inother words we mandated MainComponent to have reference and it depends on

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 18 of 30

some other components service So a new component (AddComponent) with aservice need to be created and map the MainComponent reference to the service ofAddComponent as highlighted in Figure 16

Figure 16 Wiring MainComponent reference to AddComponent service

bull The steps for creating AddComponent and service are similar toMainComponent

bull The MainComponent implementation should have reference definition asshown in Listing 3

Listing 3 Reference definition

AddInterface addInterface

Referencepublic void setAddReference(AddInterface addInterface)

thisaddInterface=addInterface

bull MainComponent reference and AddComponent service should be boundto SCA binding as shown in properties window of Figure 18 This is notmandatory by default if not chosen any bindings for a service orreference default SCA bindings are applied automatically

bull The AddComponent implementation class should be as shown in Listing4

Listing 4 AddComponent implementation

package comibmscasampleimport orgosoascaannotationsService

Service (AddInterfaceclass)public class AddInterfaceImpl implements AddInterface

public int add(int firstValue int secordValue) return firstValue+secordValue

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 19 of 30

Similarly SubstractComponent MultiplyComponent and DivisionComponent and itsservices can be created and wired to the MainComponents different referencesUpon creating all the above components the Calculator SCA composite diagramshould look as shown in Figure 17

Figure 17 Calculator SCA composite diagram

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 20 of 30

Create Contribution

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 21 of 30

Contribution can be created for the Calculator composite using RAD wizards asshown in Figure 18

Figure 18 Creating Contribution

Once the contribution is created it can be added to deploy on the local WebSphereApplication Server instance as shown in Figure 19 and Figure 20

Figure 19 AddingRemoving projects

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 22 of 30

Figure 20 Adding Calculator project

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 23 of 30

Note The contribution can also be exported as SCA archive file for deployment intoWebSphere Application Server external to the RAD

Servlet client using SCA Calculator application

This section describes how to use the Calculator SCA applicationMainComponenent service from a Servlet application

bull Create a Dynamic Web project from the RAD workspace

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 24 of 30

bull Make sure the WSDL can be located athttpserver-namehttp-portMainComponentCalculatorInterfacewsdl

Create the WSDL stub classes using following steps

1 Open File gt New gt Other and select Web service client project

2 Specifyhttpserver-namehttp-portMainComponentCalculatorInterfacewsdl inthe service definition

3 Specify the Develop client as highlighted in Figure 21 and click Nextbutton

Figure 21 Web service client

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 25 of 30

4 Specify the package comibmscastubs as shown in Figure 22 and clickon Finish

Figure 22 Specify stub classes package

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 26 of 30

The Servlet can use the code as highlighted in Listing 5 below

Listing 5 Web service stub APIs

import comibmscastubsCalculatorInterfaceimport comibmscastubsCalculatorInterfaceServiceCalculatorInterfaceService service = new CalculatorInterfaceService()CalculatorInterface ci = (CalculatorInterface) servicegetCalculatorInterfacePort()

int result = cicalculate(firstValue secondValue operation)

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 27 of 30

Working with supplied sample

This section describes the steps required to deploy the Calculator SCA sample anddeploying the SCA Servlet client application and working with it

bull Download and extract the downloadzip file located in the downloadsection

bull Run the following command to deploy the SCA application as BLA andalso deploying the Servlet client

bull Unix platformswsadminsh ndashf deploypy

bull Windows platformwsadminbat ndashf deploypy

bull To undeploy the samples run the following command

bull Unix platformswsadminsh ndashf undeploypy

bull Windows platformwsadminbat ndashf undeploypy

bull To run the sample application open the following URLhttpserver-namehttp-portSCAClient

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 28 of 30

Downloads

Description Name Size Downloadmethod

Sample downloads scripts for thisarticle

DoNotLeaveThisLinkzip 10KB HTTP

Information about download methods

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 29 of 30

Resources

bull Rational Application Developer Information Center

bull Education Assistant for WebSphere Application Server V70 Feature Pack forService Component Architecture

bull Exploring the WebSphere Application Server Feature Pack for SCA Part 1 Anoverview of the Service Component Architecture feature pack (Dec 2008) is anintroduction to open Service Component Architecture (SCA) conceptsobjectives of the technology and highlights of some key integration points

About the author

Lokanadham NallaLokanadham Nalla is a TXSeries Developer located in India SoftwareLabs Bangalore India with expertise in Java J2EE and SOAtechnologies

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 30 of 30

  • Table of Contents
  • Overview
  • Installation
  • Developing SCA applications using RAD
  • Servlet client using SCA Calculator application
  • Working with supplied sample
  • Downloads
  • Resources
  • About the author
Page 10: Developing service component architecture applications using rational application developer

Create SCA Component

Expand CalculatorProject gt SCA Content gt Composites gt httpcalculator gt andright click on CalculatorComposite Select option New gt SCA Component as shownin Figure 7

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 10 of 30

Figure 7 Create SCA Component

Specify Component name as MainComponent as specified in Figure 8 and click onFinish button

Figure 8 SCA Component options

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 11 of 30

MainComponent image is created on the composite diagram as shown in Figure 9

Figure 9 MainComponent

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 12 of 30

Adding service or reference to a Component

Right click on the MainComponent image to create a service and a reference asshown in Figure 10 and Figure 11 Name the service as CalculatorInterface and thereference as addReference

Figure 10 Adding a service

Figure 11 Adding a reference

There are two approaches for SCA service implementation top-down and

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 13 of 30

bottom-up Top-down development is used when starting with an existing WSDLBottom-up development is used when starting from existing Java code The sampleuses bottom-up approach where service Interface type is set to Java

bull Create package comibmscasample under src folder of theCalculatorProject

bull Create a new Java interface as shown in Listing 1

Listing 1 Service Interface

package comibmscasample

import orgosoascaannotationsRemotable

Remotablepublic interface CalculatorInterface

int calculate(int firstValue int secondValue String operation)

bull Make sure you have Remotable annotation is added to the interface

bull Set the service Interface property tocomibmscasamplesCalculatorInterface as highlighted in Figure 12

Figure 12 Set service interface

Note If top-down approach is used select Interface type as WSDL and specify thelocation of the WSDL in Interface

Apply binding to a service or reference

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 14 of 30

The SCA Feature Pack supports following bindings

bull Web service

bull Atom

bull HTTP

bull EJB

bull JMS

bull SCA

Users can choose to apply these binding depending on the type of client they areusing If the client application is a web service client then web service binding canbe applied If the client application is EJB client EJB bindings can be applied

In the Calculator sample application the web service binding is used so that theclient Servlet application can use the generated WSDL file for communication withCalculator SCA application Follow the below steps for applying web service bindingto the CalculatorInterface service

bull Right click on the CalculatorInterface service select Show PropertiesView option from the menu panel which displays the properties windowas shown in bottom panel of Figure 13

bull Select Binding option from the left pane of the properties window

bull List of SCA Feature Pack supported bindings are displayed after clickingon Add button on the Bindings as shown in Figure 13

bull Select web service from the list of bindings and click OK Now the webservice client APIs can be used to invoke the SCA Calculator application

bull When the Calculator application is deployed into WebSphere ApplicationServer It generates a WSDL file and it can be located using followingURLhttpserver-namehttp-portMainComponentCalculatorInterfacewsdl

Figure 13 Service properties and bindings

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 15 of 30

Similarly bindings can also be applied for a reference

Component implementation

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 16 of 30

Right click on the MainComponent and select Regenerate implementation optionas shown in Figure 14

Figure 14 Generate Implementation

bull Choose Java from the list of Implementation Type in the next window

bull Click the Next button and observe the implementation class it is going tobe generated as highlighted in Figure 15

bull Click on the Finish button to generate the implementation classcomibmscasamplesCalculatorInterfaceImpl

Figure 15 Implementation class configuration

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 17 of 30

Listing 2 below shows the generated implementation class

Listing 2 Implementation class

package comibmscasample

import orgosoascaannotationsService

Service (CalculatorInterfaceclass)public class CalculatorInterfaceImpl implements CalculatorInterface

public int calculate(int firstValue int secondValue String operation) return 0

The created reference needs to be defined in the component implementation Inother words we mandated MainComponent to have reference and it depends on

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 18 of 30

some other components service So a new component (AddComponent) with aservice need to be created and map the MainComponent reference to the service ofAddComponent as highlighted in Figure 16

Figure 16 Wiring MainComponent reference to AddComponent service

bull The steps for creating AddComponent and service are similar toMainComponent

bull The MainComponent implementation should have reference definition asshown in Listing 3

Listing 3 Reference definition

AddInterface addInterface

Referencepublic void setAddReference(AddInterface addInterface)

thisaddInterface=addInterface

bull MainComponent reference and AddComponent service should be boundto SCA binding as shown in properties window of Figure 18 This is notmandatory by default if not chosen any bindings for a service orreference default SCA bindings are applied automatically

bull The AddComponent implementation class should be as shown in Listing4

Listing 4 AddComponent implementation

package comibmscasampleimport orgosoascaannotationsService

Service (AddInterfaceclass)public class AddInterfaceImpl implements AddInterface

public int add(int firstValue int secordValue) return firstValue+secordValue

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 19 of 30

Similarly SubstractComponent MultiplyComponent and DivisionComponent and itsservices can be created and wired to the MainComponents different referencesUpon creating all the above components the Calculator SCA composite diagramshould look as shown in Figure 17

Figure 17 Calculator SCA composite diagram

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 20 of 30

Create Contribution

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 21 of 30

Contribution can be created for the Calculator composite using RAD wizards asshown in Figure 18

Figure 18 Creating Contribution

Once the contribution is created it can be added to deploy on the local WebSphereApplication Server instance as shown in Figure 19 and Figure 20

Figure 19 AddingRemoving projects

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 22 of 30

Figure 20 Adding Calculator project

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 23 of 30

Note The contribution can also be exported as SCA archive file for deployment intoWebSphere Application Server external to the RAD

Servlet client using SCA Calculator application

This section describes how to use the Calculator SCA applicationMainComponenent service from a Servlet application

bull Create a Dynamic Web project from the RAD workspace

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 24 of 30

bull Make sure the WSDL can be located athttpserver-namehttp-portMainComponentCalculatorInterfacewsdl

Create the WSDL stub classes using following steps

1 Open File gt New gt Other and select Web service client project

2 Specifyhttpserver-namehttp-portMainComponentCalculatorInterfacewsdl inthe service definition

3 Specify the Develop client as highlighted in Figure 21 and click Nextbutton

Figure 21 Web service client

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 25 of 30

4 Specify the package comibmscastubs as shown in Figure 22 and clickon Finish

Figure 22 Specify stub classes package

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 26 of 30

The Servlet can use the code as highlighted in Listing 5 below

Listing 5 Web service stub APIs

import comibmscastubsCalculatorInterfaceimport comibmscastubsCalculatorInterfaceServiceCalculatorInterfaceService service = new CalculatorInterfaceService()CalculatorInterface ci = (CalculatorInterface) servicegetCalculatorInterfacePort()

int result = cicalculate(firstValue secondValue operation)

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 27 of 30

Working with supplied sample

This section describes the steps required to deploy the Calculator SCA sample anddeploying the SCA Servlet client application and working with it

bull Download and extract the downloadzip file located in the downloadsection

bull Run the following command to deploy the SCA application as BLA andalso deploying the Servlet client

bull Unix platformswsadminsh ndashf deploypy

bull Windows platformwsadminbat ndashf deploypy

bull To undeploy the samples run the following command

bull Unix platformswsadminsh ndashf undeploypy

bull Windows platformwsadminbat ndashf undeploypy

bull To run the sample application open the following URLhttpserver-namehttp-portSCAClient

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 28 of 30

Downloads

Description Name Size Downloadmethod

Sample downloads scripts for thisarticle

DoNotLeaveThisLinkzip 10KB HTTP

Information about download methods

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 29 of 30

Resources

bull Rational Application Developer Information Center

bull Education Assistant for WebSphere Application Server V70 Feature Pack forService Component Architecture

bull Exploring the WebSphere Application Server Feature Pack for SCA Part 1 Anoverview of the Service Component Architecture feature pack (Dec 2008) is anintroduction to open Service Component Architecture (SCA) conceptsobjectives of the technology and highlights of some key integration points

About the author

Lokanadham NallaLokanadham Nalla is a TXSeries Developer located in India SoftwareLabs Bangalore India with expertise in Java J2EE and SOAtechnologies

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 30 of 30

  • Table of Contents
  • Overview
  • Installation
  • Developing SCA applications using RAD
  • Servlet client using SCA Calculator application
  • Working with supplied sample
  • Downloads
  • Resources
  • About the author
Page 11: Developing service component architecture applications using rational application developer

Figure 7 Create SCA Component

Specify Component name as MainComponent as specified in Figure 8 and click onFinish button

Figure 8 SCA Component options

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 11 of 30

MainComponent image is created on the composite diagram as shown in Figure 9

Figure 9 MainComponent

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 12 of 30

Adding service or reference to a Component

Right click on the MainComponent image to create a service and a reference asshown in Figure 10 and Figure 11 Name the service as CalculatorInterface and thereference as addReference

Figure 10 Adding a service

Figure 11 Adding a reference

There are two approaches for SCA service implementation top-down and

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 13 of 30

bottom-up Top-down development is used when starting with an existing WSDLBottom-up development is used when starting from existing Java code The sampleuses bottom-up approach where service Interface type is set to Java

bull Create package comibmscasample under src folder of theCalculatorProject

bull Create a new Java interface as shown in Listing 1

Listing 1 Service Interface

package comibmscasample

import orgosoascaannotationsRemotable

Remotablepublic interface CalculatorInterface

int calculate(int firstValue int secondValue String operation)

bull Make sure you have Remotable annotation is added to the interface

bull Set the service Interface property tocomibmscasamplesCalculatorInterface as highlighted in Figure 12

Figure 12 Set service interface

Note If top-down approach is used select Interface type as WSDL and specify thelocation of the WSDL in Interface

Apply binding to a service or reference

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 14 of 30

The SCA Feature Pack supports following bindings

bull Web service

bull Atom

bull HTTP

bull EJB

bull JMS

bull SCA

Users can choose to apply these binding depending on the type of client they areusing If the client application is a web service client then web service binding canbe applied If the client application is EJB client EJB bindings can be applied

In the Calculator sample application the web service binding is used so that theclient Servlet application can use the generated WSDL file for communication withCalculator SCA application Follow the below steps for applying web service bindingto the CalculatorInterface service

bull Right click on the CalculatorInterface service select Show PropertiesView option from the menu panel which displays the properties windowas shown in bottom panel of Figure 13

bull Select Binding option from the left pane of the properties window

bull List of SCA Feature Pack supported bindings are displayed after clickingon Add button on the Bindings as shown in Figure 13

bull Select web service from the list of bindings and click OK Now the webservice client APIs can be used to invoke the SCA Calculator application

bull When the Calculator application is deployed into WebSphere ApplicationServer It generates a WSDL file and it can be located using followingURLhttpserver-namehttp-portMainComponentCalculatorInterfacewsdl

Figure 13 Service properties and bindings

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 15 of 30

Similarly bindings can also be applied for a reference

Component implementation

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 16 of 30

Right click on the MainComponent and select Regenerate implementation optionas shown in Figure 14

Figure 14 Generate Implementation

bull Choose Java from the list of Implementation Type in the next window

bull Click the Next button and observe the implementation class it is going tobe generated as highlighted in Figure 15

bull Click on the Finish button to generate the implementation classcomibmscasamplesCalculatorInterfaceImpl

Figure 15 Implementation class configuration

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 17 of 30

Listing 2 below shows the generated implementation class

Listing 2 Implementation class

package comibmscasample

import orgosoascaannotationsService

Service (CalculatorInterfaceclass)public class CalculatorInterfaceImpl implements CalculatorInterface

public int calculate(int firstValue int secondValue String operation) return 0

The created reference needs to be defined in the component implementation Inother words we mandated MainComponent to have reference and it depends on

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 18 of 30

some other components service So a new component (AddComponent) with aservice need to be created and map the MainComponent reference to the service ofAddComponent as highlighted in Figure 16

Figure 16 Wiring MainComponent reference to AddComponent service

bull The steps for creating AddComponent and service are similar toMainComponent

bull The MainComponent implementation should have reference definition asshown in Listing 3

Listing 3 Reference definition

AddInterface addInterface

Referencepublic void setAddReference(AddInterface addInterface)

thisaddInterface=addInterface

bull MainComponent reference and AddComponent service should be boundto SCA binding as shown in properties window of Figure 18 This is notmandatory by default if not chosen any bindings for a service orreference default SCA bindings are applied automatically

bull The AddComponent implementation class should be as shown in Listing4

Listing 4 AddComponent implementation

package comibmscasampleimport orgosoascaannotationsService

Service (AddInterfaceclass)public class AddInterfaceImpl implements AddInterface

public int add(int firstValue int secordValue) return firstValue+secordValue

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 19 of 30

Similarly SubstractComponent MultiplyComponent and DivisionComponent and itsservices can be created and wired to the MainComponents different referencesUpon creating all the above components the Calculator SCA composite diagramshould look as shown in Figure 17

Figure 17 Calculator SCA composite diagram

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 20 of 30

Create Contribution

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 21 of 30

Contribution can be created for the Calculator composite using RAD wizards asshown in Figure 18

Figure 18 Creating Contribution

Once the contribution is created it can be added to deploy on the local WebSphereApplication Server instance as shown in Figure 19 and Figure 20

Figure 19 AddingRemoving projects

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 22 of 30

Figure 20 Adding Calculator project

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 23 of 30

Note The contribution can also be exported as SCA archive file for deployment intoWebSphere Application Server external to the RAD

Servlet client using SCA Calculator application

This section describes how to use the Calculator SCA applicationMainComponenent service from a Servlet application

bull Create a Dynamic Web project from the RAD workspace

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 24 of 30

bull Make sure the WSDL can be located athttpserver-namehttp-portMainComponentCalculatorInterfacewsdl

Create the WSDL stub classes using following steps

1 Open File gt New gt Other and select Web service client project

2 Specifyhttpserver-namehttp-portMainComponentCalculatorInterfacewsdl inthe service definition

3 Specify the Develop client as highlighted in Figure 21 and click Nextbutton

Figure 21 Web service client

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 25 of 30

4 Specify the package comibmscastubs as shown in Figure 22 and clickon Finish

Figure 22 Specify stub classes package

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 26 of 30

The Servlet can use the code as highlighted in Listing 5 below

Listing 5 Web service stub APIs

import comibmscastubsCalculatorInterfaceimport comibmscastubsCalculatorInterfaceServiceCalculatorInterfaceService service = new CalculatorInterfaceService()CalculatorInterface ci = (CalculatorInterface) servicegetCalculatorInterfacePort()

int result = cicalculate(firstValue secondValue operation)

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 27 of 30

Working with supplied sample

This section describes the steps required to deploy the Calculator SCA sample anddeploying the SCA Servlet client application and working with it

bull Download and extract the downloadzip file located in the downloadsection

bull Run the following command to deploy the SCA application as BLA andalso deploying the Servlet client

bull Unix platformswsadminsh ndashf deploypy

bull Windows platformwsadminbat ndashf deploypy

bull To undeploy the samples run the following command

bull Unix platformswsadminsh ndashf undeploypy

bull Windows platformwsadminbat ndashf undeploypy

bull To run the sample application open the following URLhttpserver-namehttp-portSCAClient

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 28 of 30

Downloads

Description Name Size Downloadmethod

Sample downloads scripts for thisarticle

DoNotLeaveThisLinkzip 10KB HTTP

Information about download methods

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 29 of 30

Resources

bull Rational Application Developer Information Center

bull Education Assistant for WebSphere Application Server V70 Feature Pack forService Component Architecture

bull Exploring the WebSphere Application Server Feature Pack for SCA Part 1 Anoverview of the Service Component Architecture feature pack (Dec 2008) is anintroduction to open Service Component Architecture (SCA) conceptsobjectives of the technology and highlights of some key integration points

About the author

Lokanadham NallaLokanadham Nalla is a TXSeries Developer located in India SoftwareLabs Bangalore India with expertise in Java J2EE and SOAtechnologies

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 30 of 30

  • Table of Contents
  • Overview
  • Installation
  • Developing SCA applications using RAD
  • Servlet client using SCA Calculator application
  • Working with supplied sample
  • Downloads
  • Resources
  • About the author
Page 12: Developing service component architecture applications using rational application developer

MainComponent image is created on the composite diagram as shown in Figure 9

Figure 9 MainComponent

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 12 of 30

Adding service or reference to a Component

Right click on the MainComponent image to create a service and a reference asshown in Figure 10 and Figure 11 Name the service as CalculatorInterface and thereference as addReference

Figure 10 Adding a service

Figure 11 Adding a reference

There are two approaches for SCA service implementation top-down and

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 13 of 30

bottom-up Top-down development is used when starting with an existing WSDLBottom-up development is used when starting from existing Java code The sampleuses bottom-up approach where service Interface type is set to Java

bull Create package comibmscasample under src folder of theCalculatorProject

bull Create a new Java interface as shown in Listing 1

Listing 1 Service Interface

package comibmscasample

import orgosoascaannotationsRemotable

Remotablepublic interface CalculatorInterface

int calculate(int firstValue int secondValue String operation)

bull Make sure you have Remotable annotation is added to the interface

bull Set the service Interface property tocomibmscasamplesCalculatorInterface as highlighted in Figure 12

Figure 12 Set service interface

Note If top-down approach is used select Interface type as WSDL and specify thelocation of the WSDL in Interface

Apply binding to a service or reference

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 14 of 30

The SCA Feature Pack supports following bindings

bull Web service

bull Atom

bull HTTP

bull EJB

bull JMS

bull SCA

Users can choose to apply these binding depending on the type of client they areusing If the client application is a web service client then web service binding canbe applied If the client application is EJB client EJB bindings can be applied

In the Calculator sample application the web service binding is used so that theclient Servlet application can use the generated WSDL file for communication withCalculator SCA application Follow the below steps for applying web service bindingto the CalculatorInterface service

bull Right click on the CalculatorInterface service select Show PropertiesView option from the menu panel which displays the properties windowas shown in bottom panel of Figure 13

bull Select Binding option from the left pane of the properties window

bull List of SCA Feature Pack supported bindings are displayed after clickingon Add button on the Bindings as shown in Figure 13

bull Select web service from the list of bindings and click OK Now the webservice client APIs can be used to invoke the SCA Calculator application

bull When the Calculator application is deployed into WebSphere ApplicationServer It generates a WSDL file and it can be located using followingURLhttpserver-namehttp-portMainComponentCalculatorInterfacewsdl

Figure 13 Service properties and bindings

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 15 of 30

Similarly bindings can also be applied for a reference

Component implementation

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 16 of 30

Right click on the MainComponent and select Regenerate implementation optionas shown in Figure 14

Figure 14 Generate Implementation

bull Choose Java from the list of Implementation Type in the next window

bull Click the Next button and observe the implementation class it is going tobe generated as highlighted in Figure 15

bull Click on the Finish button to generate the implementation classcomibmscasamplesCalculatorInterfaceImpl

Figure 15 Implementation class configuration

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 17 of 30

Listing 2 below shows the generated implementation class

Listing 2 Implementation class

package comibmscasample

import orgosoascaannotationsService

Service (CalculatorInterfaceclass)public class CalculatorInterfaceImpl implements CalculatorInterface

public int calculate(int firstValue int secondValue String operation) return 0

The created reference needs to be defined in the component implementation Inother words we mandated MainComponent to have reference and it depends on

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 18 of 30

some other components service So a new component (AddComponent) with aservice need to be created and map the MainComponent reference to the service ofAddComponent as highlighted in Figure 16

Figure 16 Wiring MainComponent reference to AddComponent service

bull The steps for creating AddComponent and service are similar toMainComponent

bull The MainComponent implementation should have reference definition asshown in Listing 3

Listing 3 Reference definition

AddInterface addInterface

Referencepublic void setAddReference(AddInterface addInterface)

thisaddInterface=addInterface

bull MainComponent reference and AddComponent service should be boundto SCA binding as shown in properties window of Figure 18 This is notmandatory by default if not chosen any bindings for a service orreference default SCA bindings are applied automatically

bull The AddComponent implementation class should be as shown in Listing4

Listing 4 AddComponent implementation

package comibmscasampleimport orgosoascaannotationsService

Service (AddInterfaceclass)public class AddInterfaceImpl implements AddInterface

public int add(int firstValue int secordValue) return firstValue+secordValue

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 19 of 30

Similarly SubstractComponent MultiplyComponent and DivisionComponent and itsservices can be created and wired to the MainComponents different referencesUpon creating all the above components the Calculator SCA composite diagramshould look as shown in Figure 17

Figure 17 Calculator SCA composite diagram

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 20 of 30

Create Contribution

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 21 of 30

Contribution can be created for the Calculator composite using RAD wizards asshown in Figure 18

Figure 18 Creating Contribution

Once the contribution is created it can be added to deploy on the local WebSphereApplication Server instance as shown in Figure 19 and Figure 20

Figure 19 AddingRemoving projects

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 22 of 30

Figure 20 Adding Calculator project

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 23 of 30

Note The contribution can also be exported as SCA archive file for deployment intoWebSphere Application Server external to the RAD

Servlet client using SCA Calculator application

This section describes how to use the Calculator SCA applicationMainComponenent service from a Servlet application

bull Create a Dynamic Web project from the RAD workspace

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 24 of 30

bull Make sure the WSDL can be located athttpserver-namehttp-portMainComponentCalculatorInterfacewsdl

Create the WSDL stub classes using following steps

1 Open File gt New gt Other and select Web service client project

2 Specifyhttpserver-namehttp-portMainComponentCalculatorInterfacewsdl inthe service definition

3 Specify the Develop client as highlighted in Figure 21 and click Nextbutton

Figure 21 Web service client

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 25 of 30

4 Specify the package comibmscastubs as shown in Figure 22 and clickon Finish

Figure 22 Specify stub classes package

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 26 of 30

The Servlet can use the code as highlighted in Listing 5 below

Listing 5 Web service stub APIs

import comibmscastubsCalculatorInterfaceimport comibmscastubsCalculatorInterfaceServiceCalculatorInterfaceService service = new CalculatorInterfaceService()CalculatorInterface ci = (CalculatorInterface) servicegetCalculatorInterfacePort()

int result = cicalculate(firstValue secondValue operation)

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 27 of 30

Working with supplied sample

This section describes the steps required to deploy the Calculator SCA sample anddeploying the SCA Servlet client application and working with it

bull Download and extract the downloadzip file located in the downloadsection

bull Run the following command to deploy the SCA application as BLA andalso deploying the Servlet client

bull Unix platformswsadminsh ndashf deploypy

bull Windows platformwsadminbat ndashf deploypy

bull To undeploy the samples run the following command

bull Unix platformswsadminsh ndashf undeploypy

bull Windows platformwsadminbat ndashf undeploypy

bull To run the sample application open the following URLhttpserver-namehttp-portSCAClient

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 28 of 30

Downloads

Description Name Size Downloadmethod

Sample downloads scripts for thisarticle

DoNotLeaveThisLinkzip 10KB HTTP

Information about download methods

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 29 of 30

Resources

bull Rational Application Developer Information Center

bull Education Assistant for WebSphere Application Server V70 Feature Pack forService Component Architecture

bull Exploring the WebSphere Application Server Feature Pack for SCA Part 1 Anoverview of the Service Component Architecture feature pack (Dec 2008) is anintroduction to open Service Component Architecture (SCA) conceptsobjectives of the technology and highlights of some key integration points

About the author

Lokanadham NallaLokanadham Nalla is a TXSeries Developer located in India SoftwareLabs Bangalore India with expertise in Java J2EE and SOAtechnologies

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 30 of 30

  • Table of Contents
  • Overview
  • Installation
  • Developing SCA applications using RAD
  • Servlet client using SCA Calculator application
  • Working with supplied sample
  • Downloads
  • Resources
  • About the author
Page 13: Developing service component architecture applications using rational application developer

Adding service or reference to a Component

Right click on the MainComponent image to create a service and a reference asshown in Figure 10 and Figure 11 Name the service as CalculatorInterface and thereference as addReference

Figure 10 Adding a service

Figure 11 Adding a reference

There are two approaches for SCA service implementation top-down and

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 13 of 30

bottom-up Top-down development is used when starting with an existing WSDLBottom-up development is used when starting from existing Java code The sampleuses bottom-up approach where service Interface type is set to Java

bull Create package comibmscasample under src folder of theCalculatorProject

bull Create a new Java interface as shown in Listing 1

Listing 1 Service Interface

package comibmscasample

import orgosoascaannotationsRemotable

Remotablepublic interface CalculatorInterface

int calculate(int firstValue int secondValue String operation)

bull Make sure you have Remotable annotation is added to the interface

bull Set the service Interface property tocomibmscasamplesCalculatorInterface as highlighted in Figure 12

Figure 12 Set service interface

Note If top-down approach is used select Interface type as WSDL and specify thelocation of the WSDL in Interface

Apply binding to a service or reference

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 14 of 30

The SCA Feature Pack supports following bindings

bull Web service

bull Atom

bull HTTP

bull EJB

bull JMS

bull SCA

Users can choose to apply these binding depending on the type of client they areusing If the client application is a web service client then web service binding canbe applied If the client application is EJB client EJB bindings can be applied

In the Calculator sample application the web service binding is used so that theclient Servlet application can use the generated WSDL file for communication withCalculator SCA application Follow the below steps for applying web service bindingto the CalculatorInterface service

bull Right click on the CalculatorInterface service select Show PropertiesView option from the menu panel which displays the properties windowas shown in bottom panel of Figure 13

bull Select Binding option from the left pane of the properties window

bull List of SCA Feature Pack supported bindings are displayed after clickingon Add button on the Bindings as shown in Figure 13

bull Select web service from the list of bindings and click OK Now the webservice client APIs can be used to invoke the SCA Calculator application

bull When the Calculator application is deployed into WebSphere ApplicationServer It generates a WSDL file and it can be located using followingURLhttpserver-namehttp-portMainComponentCalculatorInterfacewsdl

Figure 13 Service properties and bindings

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 15 of 30

Similarly bindings can also be applied for a reference

Component implementation

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 16 of 30

Right click on the MainComponent and select Regenerate implementation optionas shown in Figure 14

Figure 14 Generate Implementation

bull Choose Java from the list of Implementation Type in the next window

bull Click the Next button and observe the implementation class it is going tobe generated as highlighted in Figure 15

bull Click on the Finish button to generate the implementation classcomibmscasamplesCalculatorInterfaceImpl

Figure 15 Implementation class configuration

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 17 of 30

Listing 2 below shows the generated implementation class

Listing 2 Implementation class

package comibmscasample

import orgosoascaannotationsService

Service (CalculatorInterfaceclass)public class CalculatorInterfaceImpl implements CalculatorInterface

public int calculate(int firstValue int secondValue String operation) return 0

The created reference needs to be defined in the component implementation Inother words we mandated MainComponent to have reference and it depends on

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 18 of 30

some other components service So a new component (AddComponent) with aservice need to be created and map the MainComponent reference to the service ofAddComponent as highlighted in Figure 16

Figure 16 Wiring MainComponent reference to AddComponent service

bull The steps for creating AddComponent and service are similar toMainComponent

bull The MainComponent implementation should have reference definition asshown in Listing 3

Listing 3 Reference definition

AddInterface addInterface

Referencepublic void setAddReference(AddInterface addInterface)

thisaddInterface=addInterface

bull MainComponent reference and AddComponent service should be boundto SCA binding as shown in properties window of Figure 18 This is notmandatory by default if not chosen any bindings for a service orreference default SCA bindings are applied automatically

bull The AddComponent implementation class should be as shown in Listing4

Listing 4 AddComponent implementation

package comibmscasampleimport orgosoascaannotationsService

Service (AddInterfaceclass)public class AddInterfaceImpl implements AddInterface

public int add(int firstValue int secordValue) return firstValue+secordValue

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 19 of 30

Similarly SubstractComponent MultiplyComponent and DivisionComponent and itsservices can be created and wired to the MainComponents different referencesUpon creating all the above components the Calculator SCA composite diagramshould look as shown in Figure 17

Figure 17 Calculator SCA composite diagram

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 20 of 30

Create Contribution

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 21 of 30

Contribution can be created for the Calculator composite using RAD wizards asshown in Figure 18

Figure 18 Creating Contribution

Once the contribution is created it can be added to deploy on the local WebSphereApplication Server instance as shown in Figure 19 and Figure 20

Figure 19 AddingRemoving projects

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 22 of 30

Figure 20 Adding Calculator project

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 23 of 30

Note The contribution can also be exported as SCA archive file for deployment intoWebSphere Application Server external to the RAD

Servlet client using SCA Calculator application

This section describes how to use the Calculator SCA applicationMainComponenent service from a Servlet application

bull Create a Dynamic Web project from the RAD workspace

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 24 of 30

bull Make sure the WSDL can be located athttpserver-namehttp-portMainComponentCalculatorInterfacewsdl

Create the WSDL stub classes using following steps

1 Open File gt New gt Other and select Web service client project

2 Specifyhttpserver-namehttp-portMainComponentCalculatorInterfacewsdl inthe service definition

3 Specify the Develop client as highlighted in Figure 21 and click Nextbutton

Figure 21 Web service client

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 25 of 30

4 Specify the package comibmscastubs as shown in Figure 22 and clickon Finish

Figure 22 Specify stub classes package

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 26 of 30

The Servlet can use the code as highlighted in Listing 5 below

Listing 5 Web service stub APIs

import comibmscastubsCalculatorInterfaceimport comibmscastubsCalculatorInterfaceServiceCalculatorInterfaceService service = new CalculatorInterfaceService()CalculatorInterface ci = (CalculatorInterface) servicegetCalculatorInterfacePort()

int result = cicalculate(firstValue secondValue operation)

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 27 of 30

Working with supplied sample

This section describes the steps required to deploy the Calculator SCA sample anddeploying the SCA Servlet client application and working with it

bull Download and extract the downloadzip file located in the downloadsection

bull Run the following command to deploy the SCA application as BLA andalso deploying the Servlet client

bull Unix platformswsadminsh ndashf deploypy

bull Windows platformwsadminbat ndashf deploypy

bull To undeploy the samples run the following command

bull Unix platformswsadminsh ndashf undeploypy

bull Windows platformwsadminbat ndashf undeploypy

bull To run the sample application open the following URLhttpserver-namehttp-portSCAClient

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 28 of 30

Downloads

Description Name Size Downloadmethod

Sample downloads scripts for thisarticle

DoNotLeaveThisLinkzip 10KB HTTP

Information about download methods

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 29 of 30

Resources

bull Rational Application Developer Information Center

bull Education Assistant for WebSphere Application Server V70 Feature Pack forService Component Architecture

bull Exploring the WebSphere Application Server Feature Pack for SCA Part 1 Anoverview of the Service Component Architecture feature pack (Dec 2008) is anintroduction to open Service Component Architecture (SCA) conceptsobjectives of the technology and highlights of some key integration points

About the author

Lokanadham NallaLokanadham Nalla is a TXSeries Developer located in India SoftwareLabs Bangalore India with expertise in Java J2EE and SOAtechnologies

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 30 of 30

  • Table of Contents
  • Overview
  • Installation
  • Developing SCA applications using RAD
  • Servlet client using SCA Calculator application
  • Working with supplied sample
  • Downloads
  • Resources
  • About the author
Page 14: Developing service component architecture applications using rational application developer

bottom-up Top-down development is used when starting with an existing WSDLBottom-up development is used when starting from existing Java code The sampleuses bottom-up approach where service Interface type is set to Java

bull Create package comibmscasample under src folder of theCalculatorProject

bull Create a new Java interface as shown in Listing 1

Listing 1 Service Interface

package comibmscasample

import orgosoascaannotationsRemotable

Remotablepublic interface CalculatorInterface

int calculate(int firstValue int secondValue String operation)

bull Make sure you have Remotable annotation is added to the interface

bull Set the service Interface property tocomibmscasamplesCalculatorInterface as highlighted in Figure 12

Figure 12 Set service interface

Note If top-down approach is used select Interface type as WSDL and specify thelocation of the WSDL in Interface

Apply binding to a service or reference

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 14 of 30

The SCA Feature Pack supports following bindings

bull Web service

bull Atom

bull HTTP

bull EJB

bull JMS

bull SCA

Users can choose to apply these binding depending on the type of client they areusing If the client application is a web service client then web service binding canbe applied If the client application is EJB client EJB bindings can be applied

In the Calculator sample application the web service binding is used so that theclient Servlet application can use the generated WSDL file for communication withCalculator SCA application Follow the below steps for applying web service bindingto the CalculatorInterface service

bull Right click on the CalculatorInterface service select Show PropertiesView option from the menu panel which displays the properties windowas shown in bottom panel of Figure 13

bull Select Binding option from the left pane of the properties window

bull List of SCA Feature Pack supported bindings are displayed after clickingon Add button on the Bindings as shown in Figure 13

bull Select web service from the list of bindings and click OK Now the webservice client APIs can be used to invoke the SCA Calculator application

bull When the Calculator application is deployed into WebSphere ApplicationServer It generates a WSDL file and it can be located using followingURLhttpserver-namehttp-portMainComponentCalculatorInterfacewsdl

Figure 13 Service properties and bindings

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 15 of 30

Similarly bindings can also be applied for a reference

Component implementation

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 16 of 30

Right click on the MainComponent and select Regenerate implementation optionas shown in Figure 14

Figure 14 Generate Implementation

bull Choose Java from the list of Implementation Type in the next window

bull Click the Next button and observe the implementation class it is going tobe generated as highlighted in Figure 15

bull Click on the Finish button to generate the implementation classcomibmscasamplesCalculatorInterfaceImpl

Figure 15 Implementation class configuration

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 17 of 30

Listing 2 below shows the generated implementation class

Listing 2 Implementation class

package comibmscasample

import orgosoascaannotationsService

Service (CalculatorInterfaceclass)public class CalculatorInterfaceImpl implements CalculatorInterface

public int calculate(int firstValue int secondValue String operation) return 0

The created reference needs to be defined in the component implementation Inother words we mandated MainComponent to have reference and it depends on

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 18 of 30

some other components service So a new component (AddComponent) with aservice need to be created and map the MainComponent reference to the service ofAddComponent as highlighted in Figure 16

Figure 16 Wiring MainComponent reference to AddComponent service

bull The steps for creating AddComponent and service are similar toMainComponent

bull The MainComponent implementation should have reference definition asshown in Listing 3

Listing 3 Reference definition

AddInterface addInterface

Referencepublic void setAddReference(AddInterface addInterface)

thisaddInterface=addInterface

bull MainComponent reference and AddComponent service should be boundto SCA binding as shown in properties window of Figure 18 This is notmandatory by default if not chosen any bindings for a service orreference default SCA bindings are applied automatically

bull The AddComponent implementation class should be as shown in Listing4

Listing 4 AddComponent implementation

package comibmscasampleimport orgosoascaannotationsService

Service (AddInterfaceclass)public class AddInterfaceImpl implements AddInterface

public int add(int firstValue int secordValue) return firstValue+secordValue

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 19 of 30

Similarly SubstractComponent MultiplyComponent and DivisionComponent and itsservices can be created and wired to the MainComponents different referencesUpon creating all the above components the Calculator SCA composite diagramshould look as shown in Figure 17

Figure 17 Calculator SCA composite diagram

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 20 of 30

Create Contribution

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 21 of 30

Contribution can be created for the Calculator composite using RAD wizards asshown in Figure 18

Figure 18 Creating Contribution

Once the contribution is created it can be added to deploy on the local WebSphereApplication Server instance as shown in Figure 19 and Figure 20

Figure 19 AddingRemoving projects

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 22 of 30

Figure 20 Adding Calculator project

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 23 of 30

Note The contribution can also be exported as SCA archive file for deployment intoWebSphere Application Server external to the RAD

Servlet client using SCA Calculator application

This section describes how to use the Calculator SCA applicationMainComponenent service from a Servlet application

bull Create a Dynamic Web project from the RAD workspace

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 24 of 30

bull Make sure the WSDL can be located athttpserver-namehttp-portMainComponentCalculatorInterfacewsdl

Create the WSDL stub classes using following steps

1 Open File gt New gt Other and select Web service client project

2 Specifyhttpserver-namehttp-portMainComponentCalculatorInterfacewsdl inthe service definition

3 Specify the Develop client as highlighted in Figure 21 and click Nextbutton

Figure 21 Web service client

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 25 of 30

4 Specify the package comibmscastubs as shown in Figure 22 and clickon Finish

Figure 22 Specify stub classes package

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 26 of 30

The Servlet can use the code as highlighted in Listing 5 below

Listing 5 Web service stub APIs

import comibmscastubsCalculatorInterfaceimport comibmscastubsCalculatorInterfaceServiceCalculatorInterfaceService service = new CalculatorInterfaceService()CalculatorInterface ci = (CalculatorInterface) servicegetCalculatorInterfacePort()

int result = cicalculate(firstValue secondValue operation)

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 27 of 30

Working with supplied sample

This section describes the steps required to deploy the Calculator SCA sample anddeploying the SCA Servlet client application and working with it

bull Download and extract the downloadzip file located in the downloadsection

bull Run the following command to deploy the SCA application as BLA andalso deploying the Servlet client

bull Unix platformswsadminsh ndashf deploypy

bull Windows platformwsadminbat ndashf deploypy

bull To undeploy the samples run the following command

bull Unix platformswsadminsh ndashf undeploypy

bull Windows platformwsadminbat ndashf undeploypy

bull To run the sample application open the following URLhttpserver-namehttp-portSCAClient

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 28 of 30

Downloads

Description Name Size Downloadmethod

Sample downloads scripts for thisarticle

DoNotLeaveThisLinkzip 10KB HTTP

Information about download methods

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 29 of 30

Resources

bull Rational Application Developer Information Center

bull Education Assistant for WebSphere Application Server V70 Feature Pack forService Component Architecture

bull Exploring the WebSphere Application Server Feature Pack for SCA Part 1 Anoverview of the Service Component Architecture feature pack (Dec 2008) is anintroduction to open Service Component Architecture (SCA) conceptsobjectives of the technology and highlights of some key integration points

About the author

Lokanadham NallaLokanadham Nalla is a TXSeries Developer located in India SoftwareLabs Bangalore India with expertise in Java J2EE and SOAtechnologies

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 30 of 30

  • Table of Contents
  • Overview
  • Installation
  • Developing SCA applications using RAD
  • Servlet client using SCA Calculator application
  • Working with supplied sample
  • Downloads
  • Resources
  • About the author
Page 15: Developing service component architecture applications using rational application developer

The SCA Feature Pack supports following bindings

bull Web service

bull Atom

bull HTTP

bull EJB

bull JMS

bull SCA

Users can choose to apply these binding depending on the type of client they areusing If the client application is a web service client then web service binding canbe applied If the client application is EJB client EJB bindings can be applied

In the Calculator sample application the web service binding is used so that theclient Servlet application can use the generated WSDL file for communication withCalculator SCA application Follow the below steps for applying web service bindingto the CalculatorInterface service

bull Right click on the CalculatorInterface service select Show PropertiesView option from the menu panel which displays the properties windowas shown in bottom panel of Figure 13

bull Select Binding option from the left pane of the properties window

bull List of SCA Feature Pack supported bindings are displayed after clickingon Add button on the Bindings as shown in Figure 13

bull Select web service from the list of bindings and click OK Now the webservice client APIs can be used to invoke the SCA Calculator application

bull When the Calculator application is deployed into WebSphere ApplicationServer It generates a WSDL file and it can be located using followingURLhttpserver-namehttp-portMainComponentCalculatorInterfacewsdl

Figure 13 Service properties and bindings

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 15 of 30

Similarly bindings can also be applied for a reference

Component implementation

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 16 of 30

Right click on the MainComponent and select Regenerate implementation optionas shown in Figure 14

Figure 14 Generate Implementation

bull Choose Java from the list of Implementation Type in the next window

bull Click the Next button and observe the implementation class it is going tobe generated as highlighted in Figure 15

bull Click on the Finish button to generate the implementation classcomibmscasamplesCalculatorInterfaceImpl

Figure 15 Implementation class configuration

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 17 of 30

Listing 2 below shows the generated implementation class

Listing 2 Implementation class

package comibmscasample

import orgosoascaannotationsService

Service (CalculatorInterfaceclass)public class CalculatorInterfaceImpl implements CalculatorInterface

public int calculate(int firstValue int secondValue String operation) return 0

The created reference needs to be defined in the component implementation Inother words we mandated MainComponent to have reference and it depends on

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 18 of 30

some other components service So a new component (AddComponent) with aservice need to be created and map the MainComponent reference to the service ofAddComponent as highlighted in Figure 16

Figure 16 Wiring MainComponent reference to AddComponent service

bull The steps for creating AddComponent and service are similar toMainComponent

bull The MainComponent implementation should have reference definition asshown in Listing 3

Listing 3 Reference definition

AddInterface addInterface

Referencepublic void setAddReference(AddInterface addInterface)

thisaddInterface=addInterface

bull MainComponent reference and AddComponent service should be boundto SCA binding as shown in properties window of Figure 18 This is notmandatory by default if not chosen any bindings for a service orreference default SCA bindings are applied automatically

bull The AddComponent implementation class should be as shown in Listing4

Listing 4 AddComponent implementation

package comibmscasampleimport orgosoascaannotationsService

Service (AddInterfaceclass)public class AddInterfaceImpl implements AddInterface

public int add(int firstValue int secordValue) return firstValue+secordValue

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 19 of 30

Similarly SubstractComponent MultiplyComponent and DivisionComponent and itsservices can be created and wired to the MainComponents different referencesUpon creating all the above components the Calculator SCA composite diagramshould look as shown in Figure 17

Figure 17 Calculator SCA composite diagram

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 20 of 30

Create Contribution

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 21 of 30

Contribution can be created for the Calculator composite using RAD wizards asshown in Figure 18

Figure 18 Creating Contribution

Once the contribution is created it can be added to deploy on the local WebSphereApplication Server instance as shown in Figure 19 and Figure 20

Figure 19 AddingRemoving projects

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 22 of 30

Figure 20 Adding Calculator project

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 23 of 30

Note The contribution can also be exported as SCA archive file for deployment intoWebSphere Application Server external to the RAD

Servlet client using SCA Calculator application

This section describes how to use the Calculator SCA applicationMainComponenent service from a Servlet application

bull Create a Dynamic Web project from the RAD workspace

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 24 of 30

bull Make sure the WSDL can be located athttpserver-namehttp-portMainComponentCalculatorInterfacewsdl

Create the WSDL stub classes using following steps

1 Open File gt New gt Other and select Web service client project

2 Specifyhttpserver-namehttp-portMainComponentCalculatorInterfacewsdl inthe service definition

3 Specify the Develop client as highlighted in Figure 21 and click Nextbutton

Figure 21 Web service client

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 25 of 30

4 Specify the package comibmscastubs as shown in Figure 22 and clickon Finish

Figure 22 Specify stub classes package

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 26 of 30

The Servlet can use the code as highlighted in Listing 5 below

Listing 5 Web service stub APIs

import comibmscastubsCalculatorInterfaceimport comibmscastubsCalculatorInterfaceServiceCalculatorInterfaceService service = new CalculatorInterfaceService()CalculatorInterface ci = (CalculatorInterface) servicegetCalculatorInterfacePort()

int result = cicalculate(firstValue secondValue operation)

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 27 of 30

Working with supplied sample

This section describes the steps required to deploy the Calculator SCA sample anddeploying the SCA Servlet client application and working with it

bull Download and extract the downloadzip file located in the downloadsection

bull Run the following command to deploy the SCA application as BLA andalso deploying the Servlet client

bull Unix platformswsadminsh ndashf deploypy

bull Windows platformwsadminbat ndashf deploypy

bull To undeploy the samples run the following command

bull Unix platformswsadminsh ndashf undeploypy

bull Windows platformwsadminbat ndashf undeploypy

bull To run the sample application open the following URLhttpserver-namehttp-portSCAClient

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 28 of 30

Downloads

Description Name Size Downloadmethod

Sample downloads scripts for thisarticle

DoNotLeaveThisLinkzip 10KB HTTP

Information about download methods

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 29 of 30

Resources

bull Rational Application Developer Information Center

bull Education Assistant for WebSphere Application Server V70 Feature Pack forService Component Architecture

bull Exploring the WebSphere Application Server Feature Pack for SCA Part 1 Anoverview of the Service Component Architecture feature pack (Dec 2008) is anintroduction to open Service Component Architecture (SCA) conceptsobjectives of the technology and highlights of some key integration points

About the author

Lokanadham NallaLokanadham Nalla is a TXSeries Developer located in India SoftwareLabs Bangalore India with expertise in Java J2EE and SOAtechnologies

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 30 of 30

  • Table of Contents
  • Overview
  • Installation
  • Developing SCA applications using RAD
  • Servlet client using SCA Calculator application
  • Working with supplied sample
  • Downloads
  • Resources
  • About the author
Page 16: Developing service component architecture applications using rational application developer

Similarly bindings can also be applied for a reference

Component implementation

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 16 of 30

Right click on the MainComponent and select Regenerate implementation optionas shown in Figure 14

Figure 14 Generate Implementation

bull Choose Java from the list of Implementation Type in the next window

bull Click the Next button and observe the implementation class it is going tobe generated as highlighted in Figure 15

bull Click on the Finish button to generate the implementation classcomibmscasamplesCalculatorInterfaceImpl

Figure 15 Implementation class configuration

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 17 of 30

Listing 2 below shows the generated implementation class

Listing 2 Implementation class

package comibmscasample

import orgosoascaannotationsService

Service (CalculatorInterfaceclass)public class CalculatorInterfaceImpl implements CalculatorInterface

public int calculate(int firstValue int secondValue String operation) return 0

The created reference needs to be defined in the component implementation Inother words we mandated MainComponent to have reference and it depends on

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 18 of 30

some other components service So a new component (AddComponent) with aservice need to be created and map the MainComponent reference to the service ofAddComponent as highlighted in Figure 16

Figure 16 Wiring MainComponent reference to AddComponent service

bull The steps for creating AddComponent and service are similar toMainComponent

bull The MainComponent implementation should have reference definition asshown in Listing 3

Listing 3 Reference definition

AddInterface addInterface

Referencepublic void setAddReference(AddInterface addInterface)

thisaddInterface=addInterface

bull MainComponent reference and AddComponent service should be boundto SCA binding as shown in properties window of Figure 18 This is notmandatory by default if not chosen any bindings for a service orreference default SCA bindings are applied automatically

bull The AddComponent implementation class should be as shown in Listing4

Listing 4 AddComponent implementation

package comibmscasampleimport orgosoascaannotationsService

Service (AddInterfaceclass)public class AddInterfaceImpl implements AddInterface

public int add(int firstValue int secordValue) return firstValue+secordValue

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 19 of 30

Similarly SubstractComponent MultiplyComponent and DivisionComponent and itsservices can be created and wired to the MainComponents different referencesUpon creating all the above components the Calculator SCA composite diagramshould look as shown in Figure 17

Figure 17 Calculator SCA composite diagram

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 20 of 30

Create Contribution

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 21 of 30

Contribution can be created for the Calculator composite using RAD wizards asshown in Figure 18

Figure 18 Creating Contribution

Once the contribution is created it can be added to deploy on the local WebSphereApplication Server instance as shown in Figure 19 and Figure 20

Figure 19 AddingRemoving projects

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 22 of 30

Figure 20 Adding Calculator project

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 23 of 30

Note The contribution can also be exported as SCA archive file for deployment intoWebSphere Application Server external to the RAD

Servlet client using SCA Calculator application

This section describes how to use the Calculator SCA applicationMainComponenent service from a Servlet application

bull Create a Dynamic Web project from the RAD workspace

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 24 of 30

bull Make sure the WSDL can be located athttpserver-namehttp-portMainComponentCalculatorInterfacewsdl

Create the WSDL stub classes using following steps

1 Open File gt New gt Other and select Web service client project

2 Specifyhttpserver-namehttp-portMainComponentCalculatorInterfacewsdl inthe service definition

3 Specify the Develop client as highlighted in Figure 21 and click Nextbutton

Figure 21 Web service client

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 25 of 30

4 Specify the package comibmscastubs as shown in Figure 22 and clickon Finish

Figure 22 Specify stub classes package

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 26 of 30

The Servlet can use the code as highlighted in Listing 5 below

Listing 5 Web service stub APIs

import comibmscastubsCalculatorInterfaceimport comibmscastubsCalculatorInterfaceServiceCalculatorInterfaceService service = new CalculatorInterfaceService()CalculatorInterface ci = (CalculatorInterface) servicegetCalculatorInterfacePort()

int result = cicalculate(firstValue secondValue operation)

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 27 of 30

Working with supplied sample

This section describes the steps required to deploy the Calculator SCA sample anddeploying the SCA Servlet client application and working with it

bull Download and extract the downloadzip file located in the downloadsection

bull Run the following command to deploy the SCA application as BLA andalso deploying the Servlet client

bull Unix platformswsadminsh ndashf deploypy

bull Windows platformwsadminbat ndashf deploypy

bull To undeploy the samples run the following command

bull Unix platformswsadminsh ndashf undeploypy

bull Windows platformwsadminbat ndashf undeploypy

bull To run the sample application open the following URLhttpserver-namehttp-portSCAClient

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 28 of 30

Downloads

Description Name Size Downloadmethod

Sample downloads scripts for thisarticle

DoNotLeaveThisLinkzip 10KB HTTP

Information about download methods

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 29 of 30

Resources

bull Rational Application Developer Information Center

bull Education Assistant for WebSphere Application Server V70 Feature Pack forService Component Architecture

bull Exploring the WebSphere Application Server Feature Pack for SCA Part 1 Anoverview of the Service Component Architecture feature pack (Dec 2008) is anintroduction to open Service Component Architecture (SCA) conceptsobjectives of the technology and highlights of some key integration points

About the author

Lokanadham NallaLokanadham Nalla is a TXSeries Developer located in India SoftwareLabs Bangalore India with expertise in Java J2EE and SOAtechnologies

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 30 of 30

  • Table of Contents
  • Overview
  • Installation
  • Developing SCA applications using RAD
  • Servlet client using SCA Calculator application
  • Working with supplied sample
  • Downloads
  • Resources
  • About the author
Page 17: Developing service component architecture applications using rational application developer

Right click on the MainComponent and select Regenerate implementation optionas shown in Figure 14

Figure 14 Generate Implementation

bull Choose Java from the list of Implementation Type in the next window

bull Click the Next button and observe the implementation class it is going tobe generated as highlighted in Figure 15

bull Click on the Finish button to generate the implementation classcomibmscasamplesCalculatorInterfaceImpl

Figure 15 Implementation class configuration

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 17 of 30

Listing 2 below shows the generated implementation class

Listing 2 Implementation class

package comibmscasample

import orgosoascaannotationsService

Service (CalculatorInterfaceclass)public class CalculatorInterfaceImpl implements CalculatorInterface

public int calculate(int firstValue int secondValue String operation) return 0

The created reference needs to be defined in the component implementation Inother words we mandated MainComponent to have reference and it depends on

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 18 of 30

some other components service So a new component (AddComponent) with aservice need to be created and map the MainComponent reference to the service ofAddComponent as highlighted in Figure 16

Figure 16 Wiring MainComponent reference to AddComponent service

bull The steps for creating AddComponent and service are similar toMainComponent

bull The MainComponent implementation should have reference definition asshown in Listing 3

Listing 3 Reference definition

AddInterface addInterface

Referencepublic void setAddReference(AddInterface addInterface)

thisaddInterface=addInterface

bull MainComponent reference and AddComponent service should be boundto SCA binding as shown in properties window of Figure 18 This is notmandatory by default if not chosen any bindings for a service orreference default SCA bindings are applied automatically

bull The AddComponent implementation class should be as shown in Listing4

Listing 4 AddComponent implementation

package comibmscasampleimport orgosoascaannotationsService

Service (AddInterfaceclass)public class AddInterfaceImpl implements AddInterface

public int add(int firstValue int secordValue) return firstValue+secordValue

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 19 of 30

Similarly SubstractComponent MultiplyComponent and DivisionComponent and itsservices can be created and wired to the MainComponents different referencesUpon creating all the above components the Calculator SCA composite diagramshould look as shown in Figure 17

Figure 17 Calculator SCA composite diagram

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 20 of 30

Create Contribution

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 21 of 30

Contribution can be created for the Calculator composite using RAD wizards asshown in Figure 18

Figure 18 Creating Contribution

Once the contribution is created it can be added to deploy on the local WebSphereApplication Server instance as shown in Figure 19 and Figure 20

Figure 19 AddingRemoving projects

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 22 of 30

Figure 20 Adding Calculator project

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 23 of 30

Note The contribution can also be exported as SCA archive file for deployment intoWebSphere Application Server external to the RAD

Servlet client using SCA Calculator application

This section describes how to use the Calculator SCA applicationMainComponenent service from a Servlet application

bull Create a Dynamic Web project from the RAD workspace

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 24 of 30

bull Make sure the WSDL can be located athttpserver-namehttp-portMainComponentCalculatorInterfacewsdl

Create the WSDL stub classes using following steps

1 Open File gt New gt Other and select Web service client project

2 Specifyhttpserver-namehttp-portMainComponentCalculatorInterfacewsdl inthe service definition

3 Specify the Develop client as highlighted in Figure 21 and click Nextbutton

Figure 21 Web service client

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 25 of 30

4 Specify the package comibmscastubs as shown in Figure 22 and clickon Finish

Figure 22 Specify stub classes package

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 26 of 30

The Servlet can use the code as highlighted in Listing 5 below

Listing 5 Web service stub APIs

import comibmscastubsCalculatorInterfaceimport comibmscastubsCalculatorInterfaceServiceCalculatorInterfaceService service = new CalculatorInterfaceService()CalculatorInterface ci = (CalculatorInterface) servicegetCalculatorInterfacePort()

int result = cicalculate(firstValue secondValue operation)

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 27 of 30

Working with supplied sample

This section describes the steps required to deploy the Calculator SCA sample anddeploying the SCA Servlet client application and working with it

bull Download and extract the downloadzip file located in the downloadsection

bull Run the following command to deploy the SCA application as BLA andalso deploying the Servlet client

bull Unix platformswsadminsh ndashf deploypy

bull Windows platformwsadminbat ndashf deploypy

bull To undeploy the samples run the following command

bull Unix platformswsadminsh ndashf undeploypy

bull Windows platformwsadminbat ndashf undeploypy

bull To run the sample application open the following URLhttpserver-namehttp-portSCAClient

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 28 of 30

Downloads

Description Name Size Downloadmethod

Sample downloads scripts for thisarticle

DoNotLeaveThisLinkzip 10KB HTTP

Information about download methods

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 29 of 30

Resources

bull Rational Application Developer Information Center

bull Education Assistant for WebSphere Application Server V70 Feature Pack forService Component Architecture

bull Exploring the WebSphere Application Server Feature Pack for SCA Part 1 Anoverview of the Service Component Architecture feature pack (Dec 2008) is anintroduction to open Service Component Architecture (SCA) conceptsobjectives of the technology and highlights of some key integration points

About the author

Lokanadham NallaLokanadham Nalla is a TXSeries Developer located in India SoftwareLabs Bangalore India with expertise in Java J2EE and SOAtechnologies

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 30 of 30

  • Table of Contents
  • Overview
  • Installation
  • Developing SCA applications using RAD
  • Servlet client using SCA Calculator application
  • Working with supplied sample
  • Downloads
  • Resources
  • About the author
Page 18: Developing service component architecture applications using rational application developer

Listing 2 below shows the generated implementation class

Listing 2 Implementation class

package comibmscasample

import orgosoascaannotationsService

Service (CalculatorInterfaceclass)public class CalculatorInterfaceImpl implements CalculatorInterface

public int calculate(int firstValue int secondValue String operation) return 0

The created reference needs to be defined in the component implementation Inother words we mandated MainComponent to have reference and it depends on

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 18 of 30

some other components service So a new component (AddComponent) with aservice need to be created and map the MainComponent reference to the service ofAddComponent as highlighted in Figure 16

Figure 16 Wiring MainComponent reference to AddComponent service

bull The steps for creating AddComponent and service are similar toMainComponent

bull The MainComponent implementation should have reference definition asshown in Listing 3

Listing 3 Reference definition

AddInterface addInterface

Referencepublic void setAddReference(AddInterface addInterface)

thisaddInterface=addInterface

bull MainComponent reference and AddComponent service should be boundto SCA binding as shown in properties window of Figure 18 This is notmandatory by default if not chosen any bindings for a service orreference default SCA bindings are applied automatically

bull The AddComponent implementation class should be as shown in Listing4

Listing 4 AddComponent implementation

package comibmscasampleimport orgosoascaannotationsService

Service (AddInterfaceclass)public class AddInterfaceImpl implements AddInterface

public int add(int firstValue int secordValue) return firstValue+secordValue

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 19 of 30

Similarly SubstractComponent MultiplyComponent and DivisionComponent and itsservices can be created and wired to the MainComponents different referencesUpon creating all the above components the Calculator SCA composite diagramshould look as shown in Figure 17

Figure 17 Calculator SCA composite diagram

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 20 of 30

Create Contribution

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 21 of 30

Contribution can be created for the Calculator composite using RAD wizards asshown in Figure 18

Figure 18 Creating Contribution

Once the contribution is created it can be added to deploy on the local WebSphereApplication Server instance as shown in Figure 19 and Figure 20

Figure 19 AddingRemoving projects

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 22 of 30

Figure 20 Adding Calculator project

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 23 of 30

Note The contribution can also be exported as SCA archive file for deployment intoWebSphere Application Server external to the RAD

Servlet client using SCA Calculator application

This section describes how to use the Calculator SCA applicationMainComponenent service from a Servlet application

bull Create a Dynamic Web project from the RAD workspace

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 24 of 30

bull Make sure the WSDL can be located athttpserver-namehttp-portMainComponentCalculatorInterfacewsdl

Create the WSDL stub classes using following steps

1 Open File gt New gt Other and select Web service client project

2 Specifyhttpserver-namehttp-portMainComponentCalculatorInterfacewsdl inthe service definition

3 Specify the Develop client as highlighted in Figure 21 and click Nextbutton

Figure 21 Web service client

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 25 of 30

4 Specify the package comibmscastubs as shown in Figure 22 and clickon Finish

Figure 22 Specify stub classes package

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 26 of 30

The Servlet can use the code as highlighted in Listing 5 below

Listing 5 Web service stub APIs

import comibmscastubsCalculatorInterfaceimport comibmscastubsCalculatorInterfaceServiceCalculatorInterfaceService service = new CalculatorInterfaceService()CalculatorInterface ci = (CalculatorInterface) servicegetCalculatorInterfacePort()

int result = cicalculate(firstValue secondValue operation)

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 27 of 30

Working with supplied sample

This section describes the steps required to deploy the Calculator SCA sample anddeploying the SCA Servlet client application and working with it

bull Download and extract the downloadzip file located in the downloadsection

bull Run the following command to deploy the SCA application as BLA andalso deploying the Servlet client

bull Unix platformswsadminsh ndashf deploypy

bull Windows platformwsadminbat ndashf deploypy

bull To undeploy the samples run the following command

bull Unix platformswsadminsh ndashf undeploypy

bull Windows platformwsadminbat ndashf undeploypy

bull To run the sample application open the following URLhttpserver-namehttp-portSCAClient

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 28 of 30

Downloads

Description Name Size Downloadmethod

Sample downloads scripts for thisarticle

DoNotLeaveThisLinkzip 10KB HTTP

Information about download methods

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 29 of 30

Resources

bull Rational Application Developer Information Center

bull Education Assistant for WebSphere Application Server V70 Feature Pack forService Component Architecture

bull Exploring the WebSphere Application Server Feature Pack for SCA Part 1 Anoverview of the Service Component Architecture feature pack (Dec 2008) is anintroduction to open Service Component Architecture (SCA) conceptsobjectives of the technology and highlights of some key integration points

About the author

Lokanadham NallaLokanadham Nalla is a TXSeries Developer located in India SoftwareLabs Bangalore India with expertise in Java J2EE and SOAtechnologies

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 30 of 30

  • Table of Contents
  • Overview
  • Installation
  • Developing SCA applications using RAD
  • Servlet client using SCA Calculator application
  • Working with supplied sample
  • Downloads
  • Resources
  • About the author
Page 19: Developing service component architecture applications using rational application developer

some other components service So a new component (AddComponent) with aservice need to be created and map the MainComponent reference to the service ofAddComponent as highlighted in Figure 16

Figure 16 Wiring MainComponent reference to AddComponent service

bull The steps for creating AddComponent and service are similar toMainComponent

bull The MainComponent implementation should have reference definition asshown in Listing 3

Listing 3 Reference definition

AddInterface addInterface

Referencepublic void setAddReference(AddInterface addInterface)

thisaddInterface=addInterface

bull MainComponent reference and AddComponent service should be boundto SCA binding as shown in properties window of Figure 18 This is notmandatory by default if not chosen any bindings for a service orreference default SCA bindings are applied automatically

bull The AddComponent implementation class should be as shown in Listing4

Listing 4 AddComponent implementation

package comibmscasampleimport orgosoascaannotationsService

Service (AddInterfaceclass)public class AddInterfaceImpl implements AddInterface

public int add(int firstValue int secordValue) return firstValue+secordValue

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 19 of 30

Similarly SubstractComponent MultiplyComponent and DivisionComponent and itsservices can be created and wired to the MainComponents different referencesUpon creating all the above components the Calculator SCA composite diagramshould look as shown in Figure 17

Figure 17 Calculator SCA composite diagram

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 20 of 30

Create Contribution

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 21 of 30

Contribution can be created for the Calculator composite using RAD wizards asshown in Figure 18

Figure 18 Creating Contribution

Once the contribution is created it can be added to deploy on the local WebSphereApplication Server instance as shown in Figure 19 and Figure 20

Figure 19 AddingRemoving projects

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 22 of 30

Figure 20 Adding Calculator project

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 23 of 30

Note The contribution can also be exported as SCA archive file for deployment intoWebSphere Application Server external to the RAD

Servlet client using SCA Calculator application

This section describes how to use the Calculator SCA applicationMainComponenent service from a Servlet application

bull Create a Dynamic Web project from the RAD workspace

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 24 of 30

bull Make sure the WSDL can be located athttpserver-namehttp-portMainComponentCalculatorInterfacewsdl

Create the WSDL stub classes using following steps

1 Open File gt New gt Other and select Web service client project

2 Specifyhttpserver-namehttp-portMainComponentCalculatorInterfacewsdl inthe service definition

3 Specify the Develop client as highlighted in Figure 21 and click Nextbutton

Figure 21 Web service client

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 25 of 30

4 Specify the package comibmscastubs as shown in Figure 22 and clickon Finish

Figure 22 Specify stub classes package

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 26 of 30

The Servlet can use the code as highlighted in Listing 5 below

Listing 5 Web service stub APIs

import comibmscastubsCalculatorInterfaceimport comibmscastubsCalculatorInterfaceServiceCalculatorInterfaceService service = new CalculatorInterfaceService()CalculatorInterface ci = (CalculatorInterface) servicegetCalculatorInterfacePort()

int result = cicalculate(firstValue secondValue operation)

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 27 of 30

Working with supplied sample

This section describes the steps required to deploy the Calculator SCA sample anddeploying the SCA Servlet client application and working with it

bull Download and extract the downloadzip file located in the downloadsection

bull Run the following command to deploy the SCA application as BLA andalso deploying the Servlet client

bull Unix platformswsadminsh ndashf deploypy

bull Windows platformwsadminbat ndashf deploypy

bull To undeploy the samples run the following command

bull Unix platformswsadminsh ndashf undeploypy

bull Windows platformwsadminbat ndashf undeploypy

bull To run the sample application open the following URLhttpserver-namehttp-portSCAClient

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 28 of 30

Downloads

Description Name Size Downloadmethod

Sample downloads scripts for thisarticle

DoNotLeaveThisLinkzip 10KB HTTP

Information about download methods

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 29 of 30

Resources

bull Rational Application Developer Information Center

bull Education Assistant for WebSphere Application Server V70 Feature Pack forService Component Architecture

bull Exploring the WebSphere Application Server Feature Pack for SCA Part 1 Anoverview of the Service Component Architecture feature pack (Dec 2008) is anintroduction to open Service Component Architecture (SCA) conceptsobjectives of the technology and highlights of some key integration points

About the author

Lokanadham NallaLokanadham Nalla is a TXSeries Developer located in India SoftwareLabs Bangalore India with expertise in Java J2EE and SOAtechnologies

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 30 of 30

  • Table of Contents
  • Overview
  • Installation
  • Developing SCA applications using RAD
  • Servlet client using SCA Calculator application
  • Working with supplied sample
  • Downloads
  • Resources
  • About the author
Page 20: Developing service component architecture applications using rational application developer

Similarly SubstractComponent MultiplyComponent and DivisionComponent and itsservices can be created and wired to the MainComponents different referencesUpon creating all the above components the Calculator SCA composite diagramshould look as shown in Figure 17

Figure 17 Calculator SCA composite diagram

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 20 of 30

Create Contribution

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 21 of 30

Contribution can be created for the Calculator composite using RAD wizards asshown in Figure 18

Figure 18 Creating Contribution

Once the contribution is created it can be added to deploy on the local WebSphereApplication Server instance as shown in Figure 19 and Figure 20

Figure 19 AddingRemoving projects

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 22 of 30

Figure 20 Adding Calculator project

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 23 of 30

Note The contribution can also be exported as SCA archive file for deployment intoWebSphere Application Server external to the RAD

Servlet client using SCA Calculator application

This section describes how to use the Calculator SCA applicationMainComponenent service from a Servlet application

bull Create a Dynamic Web project from the RAD workspace

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 24 of 30

bull Make sure the WSDL can be located athttpserver-namehttp-portMainComponentCalculatorInterfacewsdl

Create the WSDL stub classes using following steps

1 Open File gt New gt Other and select Web service client project

2 Specifyhttpserver-namehttp-portMainComponentCalculatorInterfacewsdl inthe service definition

3 Specify the Develop client as highlighted in Figure 21 and click Nextbutton

Figure 21 Web service client

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 25 of 30

4 Specify the package comibmscastubs as shown in Figure 22 and clickon Finish

Figure 22 Specify stub classes package

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 26 of 30

The Servlet can use the code as highlighted in Listing 5 below

Listing 5 Web service stub APIs

import comibmscastubsCalculatorInterfaceimport comibmscastubsCalculatorInterfaceServiceCalculatorInterfaceService service = new CalculatorInterfaceService()CalculatorInterface ci = (CalculatorInterface) servicegetCalculatorInterfacePort()

int result = cicalculate(firstValue secondValue operation)

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 27 of 30

Working with supplied sample

This section describes the steps required to deploy the Calculator SCA sample anddeploying the SCA Servlet client application and working with it

bull Download and extract the downloadzip file located in the downloadsection

bull Run the following command to deploy the SCA application as BLA andalso deploying the Servlet client

bull Unix platformswsadminsh ndashf deploypy

bull Windows platformwsadminbat ndashf deploypy

bull To undeploy the samples run the following command

bull Unix platformswsadminsh ndashf undeploypy

bull Windows platformwsadminbat ndashf undeploypy

bull To run the sample application open the following URLhttpserver-namehttp-portSCAClient

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 28 of 30

Downloads

Description Name Size Downloadmethod

Sample downloads scripts for thisarticle

DoNotLeaveThisLinkzip 10KB HTTP

Information about download methods

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 29 of 30

Resources

bull Rational Application Developer Information Center

bull Education Assistant for WebSphere Application Server V70 Feature Pack forService Component Architecture

bull Exploring the WebSphere Application Server Feature Pack for SCA Part 1 Anoverview of the Service Component Architecture feature pack (Dec 2008) is anintroduction to open Service Component Architecture (SCA) conceptsobjectives of the technology and highlights of some key integration points

About the author

Lokanadham NallaLokanadham Nalla is a TXSeries Developer located in India SoftwareLabs Bangalore India with expertise in Java J2EE and SOAtechnologies

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 30 of 30

  • Table of Contents
  • Overview
  • Installation
  • Developing SCA applications using RAD
  • Servlet client using SCA Calculator application
  • Working with supplied sample
  • Downloads
  • Resources
  • About the author
Page 21: Developing service component architecture applications using rational application developer

Create Contribution

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 21 of 30

Contribution can be created for the Calculator composite using RAD wizards asshown in Figure 18

Figure 18 Creating Contribution

Once the contribution is created it can be added to deploy on the local WebSphereApplication Server instance as shown in Figure 19 and Figure 20

Figure 19 AddingRemoving projects

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 22 of 30

Figure 20 Adding Calculator project

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 23 of 30

Note The contribution can also be exported as SCA archive file for deployment intoWebSphere Application Server external to the RAD

Servlet client using SCA Calculator application

This section describes how to use the Calculator SCA applicationMainComponenent service from a Servlet application

bull Create a Dynamic Web project from the RAD workspace

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 24 of 30

bull Make sure the WSDL can be located athttpserver-namehttp-portMainComponentCalculatorInterfacewsdl

Create the WSDL stub classes using following steps

1 Open File gt New gt Other and select Web service client project

2 Specifyhttpserver-namehttp-portMainComponentCalculatorInterfacewsdl inthe service definition

3 Specify the Develop client as highlighted in Figure 21 and click Nextbutton

Figure 21 Web service client

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 25 of 30

4 Specify the package comibmscastubs as shown in Figure 22 and clickon Finish

Figure 22 Specify stub classes package

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 26 of 30

The Servlet can use the code as highlighted in Listing 5 below

Listing 5 Web service stub APIs

import comibmscastubsCalculatorInterfaceimport comibmscastubsCalculatorInterfaceServiceCalculatorInterfaceService service = new CalculatorInterfaceService()CalculatorInterface ci = (CalculatorInterface) servicegetCalculatorInterfacePort()

int result = cicalculate(firstValue secondValue operation)

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 27 of 30

Working with supplied sample

This section describes the steps required to deploy the Calculator SCA sample anddeploying the SCA Servlet client application and working with it

bull Download and extract the downloadzip file located in the downloadsection

bull Run the following command to deploy the SCA application as BLA andalso deploying the Servlet client

bull Unix platformswsadminsh ndashf deploypy

bull Windows platformwsadminbat ndashf deploypy

bull To undeploy the samples run the following command

bull Unix platformswsadminsh ndashf undeploypy

bull Windows platformwsadminbat ndashf undeploypy

bull To run the sample application open the following URLhttpserver-namehttp-portSCAClient

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 28 of 30

Downloads

Description Name Size Downloadmethod

Sample downloads scripts for thisarticle

DoNotLeaveThisLinkzip 10KB HTTP

Information about download methods

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 29 of 30

Resources

bull Rational Application Developer Information Center

bull Education Assistant for WebSphere Application Server V70 Feature Pack forService Component Architecture

bull Exploring the WebSphere Application Server Feature Pack for SCA Part 1 Anoverview of the Service Component Architecture feature pack (Dec 2008) is anintroduction to open Service Component Architecture (SCA) conceptsobjectives of the technology and highlights of some key integration points

About the author

Lokanadham NallaLokanadham Nalla is a TXSeries Developer located in India SoftwareLabs Bangalore India with expertise in Java J2EE and SOAtechnologies

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 30 of 30

  • Table of Contents
  • Overview
  • Installation
  • Developing SCA applications using RAD
  • Servlet client using SCA Calculator application
  • Working with supplied sample
  • Downloads
  • Resources
  • About the author
Page 22: Developing service component architecture applications using rational application developer

Contribution can be created for the Calculator composite using RAD wizards asshown in Figure 18

Figure 18 Creating Contribution

Once the contribution is created it can be added to deploy on the local WebSphereApplication Server instance as shown in Figure 19 and Figure 20

Figure 19 AddingRemoving projects

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 22 of 30

Figure 20 Adding Calculator project

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 23 of 30

Note The contribution can also be exported as SCA archive file for deployment intoWebSphere Application Server external to the RAD

Servlet client using SCA Calculator application

This section describes how to use the Calculator SCA applicationMainComponenent service from a Servlet application

bull Create a Dynamic Web project from the RAD workspace

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 24 of 30

bull Make sure the WSDL can be located athttpserver-namehttp-portMainComponentCalculatorInterfacewsdl

Create the WSDL stub classes using following steps

1 Open File gt New gt Other and select Web service client project

2 Specifyhttpserver-namehttp-portMainComponentCalculatorInterfacewsdl inthe service definition

3 Specify the Develop client as highlighted in Figure 21 and click Nextbutton

Figure 21 Web service client

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 25 of 30

4 Specify the package comibmscastubs as shown in Figure 22 and clickon Finish

Figure 22 Specify stub classes package

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 26 of 30

The Servlet can use the code as highlighted in Listing 5 below

Listing 5 Web service stub APIs

import comibmscastubsCalculatorInterfaceimport comibmscastubsCalculatorInterfaceServiceCalculatorInterfaceService service = new CalculatorInterfaceService()CalculatorInterface ci = (CalculatorInterface) servicegetCalculatorInterfacePort()

int result = cicalculate(firstValue secondValue operation)

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 27 of 30

Working with supplied sample

This section describes the steps required to deploy the Calculator SCA sample anddeploying the SCA Servlet client application and working with it

bull Download and extract the downloadzip file located in the downloadsection

bull Run the following command to deploy the SCA application as BLA andalso deploying the Servlet client

bull Unix platformswsadminsh ndashf deploypy

bull Windows platformwsadminbat ndashf deploypy

bull To undeploy the samples run the following command

bull Unix platformswsadminsh ndashf undeploypy

bull Windows platformwsadminbat ndashf undeploypy

bull To run the sample application open the following URLhttpserver-namehttp-portSCAClient

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 28 of 30

Downloads

Description Name Size Downloadmethod

Sample downloads scripts for thisarticle

DoNotLeaveThisLinkzip 10KB HTTP

Information about download methods

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 29 of 30

Resources

bull Rational Application Developer Information Center

bull Education Assistant for WebSphere Application Server V70 Feature Pack forService Component Architecture

bull Exploring the WebSphere Application Server Feature Pack for SCA Part 1 Anoverview of the Service Component Architecture feature pack (Dec 2008) is anintroduction to open Service Component Architecture (SCA) conceptsobjectives of the technology and highlights of some key integration points

About the author

Lokanadham NallaLokanadham Nalla is a TXSeries Developer located in India SoftwareLabs Bangalore India with expertise in Java J2EE and SOAtechnologies

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 30 of 30

  • Table of Contents
  • Overview
  • Installation
  • Developing SCA applications using RAD
  • Servlet client using SCA Calculator application
  • Working with supplied sample
  • Downloads
  • Resources
  • About the author
Page 23: Developing service component architecture applications using rational application developer

Figure 20 Adding Calculator project

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 23 of 30

Note The contribution can also be exported as SCA archive file for deployment intoWebSphere Application Server external to the RAD

Servlet client using SCA Calculator application

This section describes how to use the Calculator SCA applicationMainComponenent service from a Servlet application

bull Create a Dynamic Web project from the RAD workspace

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 24 of 30

bull Make sure the WSDL can be located athttpserver-namehttp-portMainComponentCalculatorInterfacewsdl

Create the WSDL stub classes using following steps

1 Open File gt New gt Other and select Web service client project

2 Specifyhttpserver-namehttp-portMainComponentCalculatorInterfacewsdl inthe service definition

3 Specify the Develop client as highlighted in Figure 21 and click Nextbutton

Figure 21 Web service client

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 25 of 30

4 Specify the package comibmscastubs as shown in Figure 22 and clickon Finish

Figure 22 Specify stub classes package

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 26 of 30

The Servlet can use the code as highlighted in Listing 5 below

Listing 5 Web service stub APIs

import comibmscastubsCalculatorInterfaceimport comibmscastubsCalculatorInterfaceServiceCalculatorInterfaceService service = new CalculatorInterfaceService()CalculatorInterface ci = (CalculatorInterface) servicegetCalculatorInterfacePort()

int result = cicalculate(firstValue secondValue operation)

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 27 of 30

Working with supplied sample

This section describes the steps required to deploy the Calculator SCA sample anddeploying the SCA Servlet client application and working with it

bull Download and extract the downloadzip file located in the downloadsection

bull Run the following command to deploy the SCA application as BLA andalso deploying the Servlet client

bull Unix platformswsadminsh ndashf deploypy

bull Windows platformwsadminbat ndashf deploypy

bull To undeploy the samples run the following command

bull Unix platformswsadminsh ndashf undeploypy

bull Windows platformwsadminbat ndashf undeploypy

bull To run the sample application open the following URLhttpserver-namehttp-portSCAClient

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 28 of 30

Downloads

Description Name Size Downloadmethod

Sample downloads scripts for thisarticle

DoNotLeaveThisLinkzip 10KB HTTP

Information about download methods

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 29 of 30

Resources

bull Rational Application Developer Information Center

bull Education Assistant for WebSphere Application Server V70 Feature Pack forService Component Architecture

bull Exploring the WebSphere Application Server Feature Pack for SCA Part 1 Anoverview of the Service Component Architecture feature pack (Dec 2008) is anintroduction to open Service Component Architecture (SCA) conceptsobjectives of the technology and highlights of some key integration points

About the author

Lokanadham NallaLokanadham Nalla is a TXSeries Developer located in India SoftwareLabs Bangalore India with expertise in Java J2EE and SOAtechnologies

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 30 of 30

  • Table of Contents
  • Overview
  • Installation
  • Developing SCA applications using RAD
  • Servlet client using SCA Calculator application
  • Working with supplied sample
  • Downloads
  • Resources
  • About the author
Page 24: Developing service component architecture applications using rational application developer

Note The contribution can also be exported as SCA archive file for deployment intoWebSphere Application Server external to the RAD

Servlet client using SCA Calculator application

This section describes how to use the Calculator SCA applicationMainComponenent service from a Servlet application

bull Create a Dynamic Web project from the RAD workspace

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 24 of 30

bull Make sure the WSDL can be located athttpserver-namehttp-portMainComponentCalculatorInterfacewsdl

Create the WSDL stub classes using following steps

1 Open File gt New gt Other and select Web service client project

2 Specifyhttpserver-namehttp-portMainComponentCalculatorInterfacewsdl inthe service definition

3 Specify the Develop client as highlighted in Figure 21 and click Nextbutton

Figure 21 Web service client

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 25 of 30

4 Specify the package comibmscastubs as shown in Figure 22 and clickon Finish

Figure 22 Specify stub classes package

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 26 of 30

The Servlet can use the code as highlighted in Listing 5 below

Listing 5 Web service stub APIs

import comibmscastubsCalculatorInterfaceimport comibmscastubsCalculatorInterfaceServiceCalculatorInterfaceService service = new CalculatorInterfaceService()CalculatorInterface ci = (CalculatorInterface) servicegetCalculatorInterfacePort()

int result = cicalculate(firstValue secondValue operation)

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 27 of 30

Working with supplied sample

This section describes the steps required to deploy the Calculator SCA sample anddeploying the SCA Servlet client application and working with it

bull Download and extract the downloadzip file located in the downloadsection

bull Run the following command to deploy the SCA application as BLA andalso deploying the Servlet client

bull Unix platformswsadminsh ndashf deploypy

bull Windows platformwsadminbat ndashf deploypy

bull To undeploy the samples run the following command

bull Unix platformswsadminsh ndashf undeploypy

bull Windows platformwsadminbat ndashf undeploypy

bull To run the sample application open the following URLhttpserver-namehttp-portSCAClient

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 28 of 30

Downloads

Description Name Size Downloadmethod

Sample downloads scripts for thisarticle

DoNotLeaveThisLinkzip 10KB HTTP

Information about download methods

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 29 of 30

Resources

bull Rational Application Developer Information Center

bull Education Assistant for WebSphere Application Server V70 Feature Pack forService Component Architecture

bull Exploring the WebSphere Application Server Feature Pack for SCA Part 1 Anoverview of the Service Component Architecture feature pack (Dec 2008) is anintroduction to open Service Component Architecture (SCA) conceptsobjectives of the technology and highlights of some key integration points

About the author

Lokanadham NallaLokanadham Nalla is a TXSeries Developer located in India SoftwareLabs Bangalore India with expertise in Java J2EE and SOAtechnologies

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 30 of 30

  • Table of Contents
  • Overview
  • Installation
  • Developing SCA applications using RAD
  • Servlet client using SCA Calculator application
  • Working with supplied sample
  • Downloads
  • Resources
  • About the author
Page 25: Developing service component architecture applications using rational application developer

bull Make sure the WSDL can be located athttpserver-namehttp-portMainComponentCalculatorInterfacewsdl

Create the WSDL stub classes using following steps

1 Open File gt New gt Other and select Web service client project

2 Specifyhttpserver-namehttp-portMainComponentCalculatorInterfacewsdl inthe service definition

3 Specify the Develop client as highlighted in Figure 21 and click Nextbutton

Figure 21 Web service client

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 25 of 30

4 Specify the package comibmscastubs as shown in Figure 22 and clickon Finish

Figure 22 Specify stub classes package

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 26 of 30

The Servlet can use the code as highlighted in Listing 5 below

Listing 5 Web service stub APIs

import comibmscastubsCalculatorInterfaceimport comibmscastubsCalculatorInterfaceServiceCalculatorInterfaceService service = new CalculatorInterfaceService()CalculatorInterface ci = (CalculatorInterface) servicegetCalculatorInterfacePort()

int result = cicalculate(firstValue secondValue operation)

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 27 of 30

Working with supplied sample

This section describes the steps required to deploy the Calculator SCA sample anddeploying the SCA Servlet client application and working with it

bull Download and extract the downloadzip file located in the downloadsection

bull Run the following command to deploy the SCA application as BLA andalso deploying the Servlet client

bull Unix platformswsadminsh ndashf deploypy

bull Windows platformwsadminbat ndashf deploypy

bull To undeploy the samples run the following command

bull Unix platformswsadminsh ndashf undeploypy

bull Windows platformwsadminbat ndashf undeploypy

bull To run the sample application open the following URLhttpserver-namehttp-portSCAClient

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 28 of 30

Downloads

Description Name Size Downloadmethod

Sample downloads scripts for thisarticle

DoNotLeaveThisLinkzip 10KB HTTP

Information about download methods

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 29 of 30

Resources

bull Rational Application Developer Information Center

bull Education Assistant for WebSphere Application Server V70 Feature Pack forService Component Architecture

bull Exploring the WebSphere Application Server Feature Pack for SCA Part 1 Anoverview of the Service Component Architecture feature pack (Dec 2008) is anintroduction to open Service Component Architecture (SCA) conceptsobjectives of the technology and highlights of some key integration points

About the author

Lokanadham NallaLokanadham Nalla is a TXSeries Developer located in India SoftwareLabs Bangalore India with expertise in Java J2EE and SOAtechnologies

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 30 of 30

  • Table of Contents
  • Overview
  • Installation
  • Developing SCA applications using RAD
  • Servlet client using SCA Calculator application
  • Working with supplied sample
  • Downloads
  • Resources
  • About the author
Page 26: Developing service component architecture applications using rational application developer

4 Specify the package comibmscastubs as shown in Figure 22 and clickon Finish

Figure 22 Specify stub classes package

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 26 of 30

The Servlet can use the code as highlighted in Listing 5 below

Listing 5 Web service stub APIs

import comibmscastubsCalculatorInterfaceimport comibmscastubsCalculatorInterfaceServiceCalculatorInterfaceService service = new CalculatorInterfaceService()CalculatorInterface ci = (CalculatorInterface) servicegetCalculatorInterfacePort()

int result = cicalculate(firstValue secondValue operation)

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 27 of 30

Working with supplied sample

This section describes the steps required to deploy the Calculator SCA sample anddeploying the SCA Servlet client application and working with it

bull Download and extract the downloadzip file located in the downloadsection

bull Run the following command to deploy the SCA application as BLA andalso deploying the Servlet client

bull Unix platformswsadminsh ndashf deploypy

bull Windows platformwsadminbat ndashf deploypy

bull To undeploy the samples run the following command

bull Unix platformswsadminsh ndashf undeploypy

bull Windows platformwsadminbat ndashf undeploypy

bull To run the sample application open the following URLhttpserver-namehttp-portSCAClient

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 28 of 30

Downloads

Description Name Size Downloadmethod

Sample downloads scripts for thisarticle

DoNotLeaveThisLinkzip 10KB HTTP

Information about download methods

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 29 of 30

Resources

bull Rational Application Developer Information Center

bull Education Assistant for WebSphere Application Server V70 Feature Pack forService Component Architecture

bull Exploring the WebSphere Application Server Feature Pack for SCA Part 1 Anoverview of the Service Component Architecture feature pack (Dec 2008) is anintroduction to open Service Component Architecture (SCA) conceptsobjectives of the technology and highlights of some key integration points

About the author

Lokanadham NallaLokanadham Nalla is a TXSeries Developer located in India SoftwareLabs Bangalore India with expertise in Java J2EE and SOAtechnologies

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 30 of 30

  • Table of Contents
  • Overview
  • Installation
  • Developing SCA applications using RAD
  • Servlet client using SCA Calculator application
  • Working with supplied sample
  • Downloads
  • Resources
  • About the author
Page 27: Developing service component architecture applications using rational application developer

The Servlet can use the code as highlighted in Listing 5 below

Listing 5 Web service stub APIs

import comibmscastubsCalculatorInterfaceimport comibmscastubsCalculatorInterfaceServiceCalculatorInterfaceService service = new CalculatorInterfaceService()CalculatorInterface ci = (CalculatorInterface) servicegetCalculatorInterfacePort()

int result = cicalculate(firstValue secondValue operation)

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 27 of 30

Working with supplied sample

This section describes the steps required to deploy the Calculator SCA sample anddeploying the SCA Servlet client application and working with it

bull Download and extract the downloadzip file located in the downloadsection

bull Run the following command to deploy the SCA application as BLA andalso deploying the Servlet client

bull Unix platformswsadminsh ndashf deploypy

bull Windows platformwsadminbat ndashf deploypy

bull To undeploy the samples run the following command

bull Unix platformswsadminsh ndashf undeploypy

bull Windows platformwsadminbat ndashf undeploypy

bull To run the sample application open the following URLhttpserver-namehttp-portSCAClient

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 28 of 30

Downloads

Description Name Size Downloadmethod

Sample downloads scripts for thisarticle

DoNotLeaveThisLinkzip 10KB HTTP

Information about download methods

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 29 of 30

Resources

bull Rational Application Developer Information Center

bull Education Assistant for WebSphere Application Server V70 Feature Pack forService Component Architecture

bull Exploring the WebSphere Application Server Feature Pack for SCA Part 1 Anoverview of the Service Component Architecture feature pack (Dec 2008) is anintroduction to open Service Component Architecture (SCA) conceptsobjectives of the technology and highlights of some key integration points

About the author

Lokanadham NallaLokanadham Nalla is a TXSeries Developer located in India SoftwareLabs Bangalore India with expertise in Java J2EE and SOAtechnologies

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 30 of 30

  • Table of Contents
  • Overview
  • Installation
  • Developing SCA applications using RAD
  • Servlet client using SCA Calculator application
  • Working with supplied sample
  • Downloads
  • Resources
  • About the author
Page 28: Developing service component architecture applications using rational application developer

Working with supplied sample

This section describes the steps required to deploy the Calculator SCA sample anddeploying the SCA Servlet client application and working with it

bull Download and extract the downloadzip file located in the downloadsection

bull Run the following command to deploy the SCA application as BLA andalso deploying the Servlet client

bull Unix platformswsadminsh ndashf deploypy

bull Windows platformwsadminbat ndashf deploypy

bull To undeploy the samples run the following command

bull Unix platformswsadminsh ndashf undeploypy

bull Windows platformwsadminbat ndashf undeploypy

bull To run the sample application open the following URLhttpserver-namehttp-portSCAClient

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 28 of 30

Downloads

Description Name Size Downloadmethod

Sample downloads scripts for thisarticle

DoNotLeaveThisLinkzip 10KB HTTP

Information about download methods

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 29 of 30

Resources

bull Rational Application Developer Information Center

bull Education Assistant for WebSphere Application Server V70 Feature Pack forService Component Architecture

bull Exploring the WebSphere Application Server Feature Pack for SCA Part 1 Anoverview of the Service Component Architecture feature pack (Dec 2008) is anintroduction to open Service Component Architecture (SCA) conceptsobjectives of the technology and highlights of some key integration points

About the author

Lokanadham NallaLokanadham Nalla is a TXSeries Developer located in India SoftwareLabs Bangalore India with expertise in Java J2EE and SOAtechnologies

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 30 of 30

  • Table of Contents
  • Overview
  • Installation
  • Developing SCA applications using RAD
  • Servlet client using SCA Calculator application
  • Working with supplied sample
  • Downloads
  • Resources
  • About the author
Page 29: Developing service component architecture applications using rational application developer

Downloads

Description Name Size Downloadmethod

Sample downloads scripts for thisarticle

DoNotLeaveThisLinkzip 10KB HTTP

Information about download methods

ibmcomdeveloperWorks developerWorksreg

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 29 of 30

Resources

bull Rational Application Developer Information Center

bull Education Assistant for WebSphere Application Server V70 Feature Pack forService Component Architecture

bull Exploring the WebSphere Application Server Feature Pack for SCA Part 1 Anoverview of the Service Component Architecture feature pack (Dec 2008) is anintroduction to open Service Component Architecture (SCA) conceptsobjectives of the technology and highlights of some key integration points

About the author

Lokanadham NallaLokanadham Nalla is a TXSeries Developer located in India SoftwareLabs Bangalore India with expertise in Java J2EE and SOAtechnologies

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 30 of 30

  • Table of Contents
  • Overview
  • Installation
  • Developing SCA applications using RAD
  • Servlet client using SCA Calculator application
  • Working with supplied sample
  • Downloads
  • Resources
  • About the author
Page 30: Developing service component architecture applications using rational application developer

Resources

bull Rational Application Developer Information Center

bull Education Assistant for WebSphere Application Server V70 Feature Pack forService Component Architecture

bull Exploring the WebSphere Application Server Feature Pack for SCA Part 1 Anoverview of the Service Component Architecture feature pack (Dec 2008) is anintroduction to open Service Component Architecture (SCA) conceptsobjectives of the technology and highlights of some key integration points

About the author

Lokanadham NallaLokanadham Nalla is a TXSeries Developer located in India SoftwareLabs Bangalore India with expertise in Java J2EE and SOAtechnologies

developerWorksreg ibmcomdeveloperWorks

Developing service component architecture applications using Rational Application Developer Trademarkscopy Copyright IBM Corporation 2010 All rights reserved Page 30 of 30

  • Table of Contents
  • Overview
  • Installation
  • Developing SCA applications using RAD
  • Servlet client using SCA Calculator application
  • Working with supplied sample
  • Downloads
  • Resources
  • About the author