276 Managing Information Access to an EIS Using J2EE and Services Oriented Architecture
The IMS service that we call requires input parameters that we have to set before
we invoke the service. J2C-based services are often characterized by complex
data structures that require either a Transformation node or a Java snippet. For
the TraderEISIMSService, we demonstrate the use of Java snippets for data
transformation. Add two Java snippets to the switch case, for example
AssignIMSRequest for outbound data transformation and AssignIMSResponse
for inbound transformation. Connect the nodes so that the execution path
becomes AssignIMSRequest - InvokeIMSService - AssignIMSResponse.
Figure 9-21 shows the process flow.
Figure 9-21 J2C IMS service invocation
Chapter 9. Integration into business processes 277
Go to the Implementation tab for the InvokeIMSService activity to configure the
operation and to create variables. From the drop-down select the partner link,
port type, and operation. In our example, we selected the InvokeTrader operation
provided by the TraderEIS partner link.
To create variables that contain the input and output data for the service, click
New to the right of Request and Response, respectively. Name the variables, for
example EISServiceInput and EISServiceOutput. Figure 9-22 depicts the
resulting BPEL process.
Figure 9-22 J2C IMS service specification
278 Managing Information Access to an EIS Using J2EE and Services Oriented Architecture
To set the variables during process execution, code fragments have to be added
to the Java snippets. Go to the Implementation tab of the Java snippets to enter
code. Example 9-1 shows the code for the AssignIMSRequest snippet.
Example 9-1 Code for the AssignIMSRequest Java snippet
int insize = new INBUFFERFormatHandler().getSize();
InvokeTraderSPRequestMessage its = getProcessInput();
InvokeTraderRequestMessage itr = getEISServiceInput();
INBUFFER in = new INBUFFER();
in.setIn__zz((short) 0);
in.setIn__ll((short) insize);
in.setIn__trcd("TRADERBl");
in.setRequest__type("Buy_Sell");
in.setUpdate__buy__sell("1");
in.setUserid(its.getRequest().getStockOrderBO().getAccount());
in.setNo__of__shares__dec((short)its.getRequest().
getStockOrderBO().getQuantity());
in.setCompany__name(its.getRequest().getStockOrderBO().getStock());
itr.setINBUFFER(in);
setEISServiceInput(itr);
Example 9-2 shows the code for the AssignIMSResponse snippet.
Example 9-2 Code for the AssignIMSResult Java snippet
InvokeTraderSPResponseMessage itr = getProcessOutput();
InvokeTraderResponseMessage itrs = getEISServiceOutput();
StockOrderConfirmation confirmation = new StockOrderConfirmation();
StockOrderBO sbo = new StockOrderBO();
confirmation.setMessage("Transaction completed");
sbo.setAccount(itrs.getOUTBUFFERPart().getUserid());
sbo.setQuantity((int) itrs.getOUTBUFFERPart().getNo__of__shares__dec());
sbo.setStock(itrs.getOUTBUFFERPart().getCompany__name());
itr.setResponse(confirmation);
setProcessOutput(itr);
You can test the process at this stage.
1. Right-click the BPEL process in the Service view and select Enterprise
Services
Generate Deploy Code.
2. Accept the defaults and click OK.
WebSphere Studio Application Developer Integration Edition creates all
artifacts required to run the BPEL process, including an EJB and an
Chapter 9. Integration into business processes 279
Enterprise Application module. You might have to add Java snippets to the
other two branches, because BPEL validation can fail if empty switch cases
are detected.
Add the Enterprise Application to a WebSphere Business Integration Server
Foundation test server, publish the applications, and start the server. You can
start the business process by using the business process Web client. Refer to
the WebSphere Studio Application Developer Integration Edition help for more
details on how to test business processes.
Invoking the EIS component service using EJB binding
Because the Trader EIS component consists of EJBs, the BPEL process is able
to call the EJBs directly using the EJB binding. EJB service descriptions can be
created with the Service Creation Wizard by selecting File
New Service
built from.
We have created a service description that includes the EJB binding for the
TraderIntegration session bean of The Trader EIS component. The EJB service
description, for example TraderIntegrationEJBService.wsdl, has to be dropped
on the BPEL editor to create a partner link. The EJB-based service is called from
an Invoke activity that needs to be configured as described in the previous
section. Also, variables for inbound and outbound data need to be created.
Because the Trader EIS component accepts business objects, setting outbound
data objects and inbound objects is easier. Instead of coding the data
transformation in Java snippets, we can now use Assign activities. Assign
activities are available from the palette of the BPEL editor.
Assign activities do not contain Java code. They are configured in the
Implementation tab of their Attributes view. Data mapping is supported in the
editor by specifying the variable that provides the data in the left column. The
variable that has to be initialized is selected in the right column. The Assign
activity does not support transformation between data types. Data types of the
structures selected in both columns must match. Figure 9-23 on page 280
depicts the data mapping editor for the AssignEISRequest activity.
280 Managing Information Access to an EIS Using J2EE and Services Oriented Architecture
Figure 9-23 Mapping of process variables using an Assign activity
Invoking the EIS component service using JMS
In case a remote EIS component has to be called from the BPEL process, JMS is
used to communicate with the EIS component that is located close to the
back-end system. The Trader EIS component provides a sender bean that can
be used by a client to send requests. Also, an MDB is provided to process the
reply messages from the EIS component in the client.
To configure an Invoke activity to call the sender bean, you have to create a
service description for the sender bean. We again selected the EJB binding to
call the sender bean from the BPEL process. First, you have to drop the service
description of the sender bean on the process to create a BPEL partner link.
Then, you add an Invoke activity to the process. In the implementation tab of the
Invoke activity, specify the port type and operation of that partner link, and crate
input and output variables. You can use assign activities to set these variables.
The sender bean sends a message to the EIS components and returns. To
receive the reply from the EIS component in the BPEL process, the MDB that
receives the message has to forward it to the BPEL process. The BPEL
specification provides a specific construct, the Pick activity, to receive and
process confirmation messages from external services and systems.
To add a Pick activity to the process:
1. Select the Pick icon from the palette of the BPEL editor and drop it on the
process.
The Pick activity is similar to a Switch node because it provides multiple
onMessage branches for different messages that may arrive. In our case, we
only need one branch.
2. Highlight the Pick node and select the Add onMessage icon that appears in
the top-right of the node.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset