In this task, you create WebSphere Application Server applications that
implement interaction patterns. The applications include the following
types of projects:
- Service Project
Contains the initial .wsdl and XSD files that were deployed from
System Manager, generated .wsdl files with EJB bindings, and may
contain generated helper classes.
- EAR project
Contains one or more EJB projects (which contain generated Session and
Message Driver Beans (MDBs))
In addition to WebSphere Application Server components (EJBs and MDBs), the
tooling generates the following helper classes:
- Data-type java beans, generated for each XML Schema Definition found in
the wsdl or xsd file, with format depending only on the schema.
- Format-handler java beans, used to serialize and deserialize data-type
beans to and from wire format. The wire format (and therefore the
format handlers) are specific to the encoding and binding, as specified in the
.wsdl file. For this solution, binding is jms and encoding is
XML (reflected in the package name of the format handler class).
After you have created the projects, you can export an individual
interaction pattern as an Enterprise Application Archive (EAR) application for
deployment on a WAS server, or you can include multiple interaction patterns
in a single EAR application for deployment.
- Note:
- The final EAR project must include a a helper file, boutils.jar, that
contains the business object initialization library routine. You must
add this file to the completed EAR by importing it manually, as described
under Adding the Business Object Library Routine, later in this
section.
The topics in this section describe how to create for each interaction
pattern.
The Agent Delivery interaction pattern asynchronously delivers a message
from the adapter to WebSphere Application Server. No response message
is required from WebSphere Application Server.
To create an Agent Delivery interaction pattern, you must create an EAR
application that contains:
- A message driven bean (MDB) that receives messages and invokes the EJB
- An EJB that is triggered by the MDB and that implements the business logic
that you want to use for processing the event
- Helper classes that represent the .xsd files as java beans, and
format handler java beans that convert XML to java, as specified in the
.wsdl file.
The EAR application must also contain .wsdl and .xsd files
from the Service Project. If you chose Export to Service Project when
you deployed your System Manager user project, the Service Project already
exists and is included in the EAR. If you instead exported your System
Manager user project as individual files to a directory or as a JAR file, you
will need to import the file or files into a new Service Project.
This step is not necessary if you exported your System Manager user
project directly into an existing service project, as described in Deploying user projects. If you exported from System Manager to a JAR file or
to a directory, you will need to perform this step to import the files into a
service project. This step creates a Session Bean and .wsdl
files that describe it.
This procedure assumes that in System Manager you chose the option to
Export to a Directory. To import the exported files into a new service
project, do the following:
- In the Business Integration perspective, choose File>New>Service
Project.
- The New Service Project dialog displays. Enter a name that you want
to use for this project, accept the default for Project contents, and click
Next.

- Click Finish. The new service project is created in your default
workspace. The core libraries, and any additional elements that you
included from existing projects, are displayed in the Package Explorer view of
the Business Integration perspective.
- In the Package Explorer view, right-click on the new service project you
have created, and choose Import.
- The Import dialog displays. Select the File System folder and click
Next.

- In the Directory scroll box, browse to the folder that contains the
.wsdl files and .xsd files that you have created for use in this
interaction pattern. If you created the .xsd files and
.wsdl files for this interaction by deploying a user project from
System Manager, you should have a folder with the same name that you gave the
user project. Choose that folder, and click OK.
- The Import dialog now displays the files contained within the project
folder that you have selected. Checkboxes enable you to include or
exclude specific .xsd or .wsdl files. Your default
choice, assuming that the user project that you created in System Manager
contains only elements that are usable in the interaction pattern that you are
creating, should be to include all the .xsd and .wsdl files
displayed in the folder. However, the dialog enables you to select any
or all of the files. Typically you should have all of the business
object .xsd files that you designated as supported in the connector
configuration in the same folder with the WSDL file that was created from the
connector's configuration file. Error messages may be displayed if
the .xsd files for any supported business objects are missing from the
folder that contains the WSDL file.

- Specify the name of the destination folder for the files that you are
importing; for example, MyServices\com\ibm\cw
- Click Finish.
- In Package Explorer, the files that you imported are displayed under
the service project that you named.
The Agent Delivery interaction pattern requires an EJB to consume the
message incoming to WebSphere Application Server from the agent.
You must both create the EJB and add business logic to the EBJ method to
process the received event.
Start by creating a project that will contain the EJB:
- In the J2EE view of the Business Integration perspective, choose
File>New>Project.
- In the New Project dialog, choose EJB in the left-hand panel, then select
EJB project in the right-hand panel, and then choose Next.

- In the Select an EJB Version dialog, choose Create 2.0 EJB Project,
and click Next.

- In the EJB Project Creation Dialog, provide a name for your EJB project,
and the name of a new or existing EAR project folder to which it will be
added. If you specify a name for a new EAR project, a folder with that
project name will be created.

- Choose Finish. A project, containing an EJB module, is generated
under the name that you specified. The EJB project is created for you
and you can see it in the J2EE Hierarchy view under EJB Modules.
In the Services view, under Service Projects, select the
.wsdl interface file that you imported from your connector
configuration (for example, AgentDelConnector.wsdl). Right
click, and choose New>Build from Service. The New Service Skeleton
dialog opens.
- Choose EJB Service Skeleton and click Next.

- In the New Service Skeleton dialog, select Create a new port and
binding and select Generate helper classes. Choose
Next.
- The Service Skeleton dialog appears.

- Select the appropriate Port type name according to the interaction pattern
you are creating, and provide a meaningful package name in place of the
default. Click Next.
- In the next dialog, you can specify properties for generating the EJB
skeleton, or accept the defaults. Click Finish. The newly
created EJB project will be listed under Deployable Services in the Services
view.
- Edit the skeleton to add any necessary business logic.
A message driver bean is responsible for receiving events as messages from
the connector and invoking EJB processing of the events.
In this step, you will deploy the EJB service to the server using
existing inbound port and bindings - the original JMS bindings. This
step generates an MDB that invokes the appropriate method of the Session Bean
skeleton. The MDB is specific to the port type and the selection of the
operation is made based on the incoming message properties:
WSDLOperation (and possibly WSDLInput and WSDLOutput) properties. The
additional helper classes, format handlers, are also generated during the
deployment. These are used to convert from the wire format (the XML
message) to the Java Class, which in turn is passed as an argument to the
business method of the EJB.
You must configure the JNDI names used by the EJB and MDB. The JNDI
setup is necessary since the lookup names of the queue connection factory and
queues defined in WSDL may not match the actual names defined on your
server. The WebSphere Application Server allows you to map the name you
are looking up (as specified in WSDL) to the actual JNDI name deployed on the
server, thus allowing correct execution without the need for modification of
your wsdl files. You also need to specify what listener port is used by
the MDB.
- In the Package Explorer view, expand the folder for the Service Project
that you have created and select the EJBService .wsdl file that was
generated in the previous task. Right-click on the file, and in the
pop-up choose Enterprise Services>Generate Deploy Code.

- In the Generate Deploy Code dialog, select Use an existing
port, and choose Next

- In the Inbound Service Files dialog, select the JMSService .wsdl
file for your project, and the corresponding service name and port
name. Choose Finish.
- In the J2EE Hierarchy view, select your project under EJB Modules,
right-click, choose Open With the EJB Deployment Descriptor editor
and choose the Bean tab. Verify that the Destination type is
Queue. Specify the correct ListenerPort, so that its queue connection
factory and queue match those specified in the .wsdl file for this
interaction pattern.

- Choose the References tab. Select the resource queue name listed
under the MDB. The name from the .wsdl file then appears in the
Name box at right. Under WebSphere Bindings,in the JNDI
name field, enter the correct JNDI name for the deployment of this
queue, as defined in the WAS Administrative Console.

- Select the connector factory listed under the MDB. Under WebSphere
Bindings,in the JNDI name field, enter the correct JNDI name for
the deployment of this connection factory, as defined in the WAS
Administrative Console.

- Save the changes that you made in the EJB Deployment Descriptor
editor.
- Open the Server Configuration tab in the lower panel of the Business
Integration perspective and right-click on the Servers icon.
- Choose New, and choose Servers and Server Configuration. The
Create a New Server and Server Configuration dialog appears.

- In the Server name field, enter a name for the server instance you are
creating. Enter the same name in the Folderfield. In the Server
Type field, select EE Test Environment.
- Choose Finish, and respond Yes when prompted to create a new server
project with the name you specified.
- After the utility completes, in the Server Configuration panel
double-click the icon for the new server instance that you have
created. The WebSphere Server panel appears, with the name of the
server instance you have created. Choose the Configuration tab.
- The WebSphere Server Configuration panel appears. Put a check in
the Enable administration console checkbox.

- Choose the Variables tab. In the Defined variables dropdown box,
locate the MQ_INSTALL_ROOT variable. Change the value of the variable
to the absolute root path of your MQ installation.
- Save your configuration. (Ctrl+S).
- Start the newly configured server instances, as follows: In the
lower portion of the Business Integration perspective, choose the Servers
tab. The Servers panel displays. In the Servers panel, select
the icon for the newly configured server instance, and click the run button to
start the server.
- Open the WAS Administrative Console. Under General Properties under
the Configuration tab, add the listener port name that you specified in the
Bean tab of EJB Deployment Descriptor. Add the same connection factory
JNDI value and destination JNDI queue name value that you specified in the
References tab of EJB Deployment Descriptor. As appropriate for your
needs, make any necessary changes in the Maximum sessions, Maximum retries,
and Maximum messages fields.

- In the WAS Administrative Console, add the queue as a resource.
Provide a display name for the queue and a JNDI lookup name. The JNDI
lookup name must be the same as specified for the EJB Deployment Descriptor
and the listener port.

In the Base Queue Name field, enter the name of the physical queue that you
created in the MQ queue manager. This must correspond to the
DeliveryQueue that you specified in the connector configuration properties
using Connector Configurator.

In the JNDI Name field, enter the name of the queue that you established in
the destination JNDI queue name value in the Bean tab of EJB Deployment
Descriptor. Provide a value for Base Queue Manager Name.
- Create a queue connection factory, with the JNDI name corresponding to the
name used in the EJB Deployment Descriptor and in the listener port.
After you have completed these steps, you will have a completed EAR
application for this interaction pattern. You can then test this EAR
application in EE Test Environment and deploy the appliction as an EAR file to
another WAS server environment.
