226 Managing Information Access to an EIS Using J2EE and Services Oriented Architecture
Figure 8-18 QuoteOutput variable
3. Select QuoteInput in the variables box. In the Message tab, we use the
JDBCConnector.wsdl file to map it to the STOCK INFO Request message
type.
4. Select Message, and then click Browse. Navigate to the JDBC Adapter
project and select the JDBCAdapter.wsdl file. Then select STOCK INFO
Request from the drop-down list.
5. Select QuoteOutput in the variables box. In the Message tab, we use the
JDBCConnector.wsdl file to map it to the STOCKINFOResponse message
type.
6. Select Message, then click Browse. Navigate to the JDBCAdapter project
and select the JDBCAdapter.wsdl file. Then select STOCKINFOResponse
from the drop-down list. The result is shown in Figure 8-18.
7. Press Ctrl+S to save the BPEL process.
Creating the data transformation snippet for InputVariable
You need to create a Java Snippet activity by clicking on the Java snippet icon
and then clicking on the StockInfo Flow canvas, just between the Receive and
Reply activities.
1. Enter Assign StockInfo as the Display Name. (The name will be
automatically set without the spaces.) Use the transaction links to have the
Receive flow to the Assign StockInfo then to the Reply.
Chapter 8. Integration using WebSphere Business Integration Adapters 227
2. Click Implementation, and on the implementation tab, enter the code shown
in Example 8-4.
Example 8-4 Data transformation from input variable
STOCKINFORequestMessage requestMessage = getQuoteInput();
STOCKINFOElement infoElement = new STOCKINFOElement();
infoElement.setSYMBOL(“IBM”);
infoElement.setVerb(“Retrieve”);
requestMessage.setBodyPart(infoElement);
3. Right-click in the code tab, then select Source Organize Imports to
resolve the types.
This is where you would set the values coming from the InputVariable into the
QuoteInput variable. For now, to get the test going, you can enter literals.
Creating the invoke activity for adapter call
In this step, you create the invoke activity which makes the call on the JDBC
adapter service:
1. Create an invoke activity by clicking the Invoke icon and then clicking the
StockInfo Flow canvas.
2. Enter Invoke JDBC Adapter as the Display Name. (The name will be
automatically set without the spaces.)
3. Use the transition links to set the Invoke between the Assign StockInfo and
Reply activities.
Creating the partner link for the invoke activity
Next, you create the partner link for the EJB Service that you created earlier:
1. Change to the business integration perspective.
2. Select the JDBCAdapterEJB project. Expand the project until you reach the
ejbModule and the package com.itso.wbia.jdbc.
3. Drag the STOCKINFOHubRequestEJBService.wsdl file over to the partner
link box on the BPEL canvas. Figure 8-19 on page 228 shows the selection
dialog for the Hub Request service that appears after you drop the WSDL file
on the canvas.
228 Managing Information Access to an EIS Using J2EE and Services Oriented Architecture
Figure 8-19 STOCKINFOHubRequest Service Selection
4. Click OK to accept the service, port, and port type for the
STOCKINFOHubRequest. This is a synchronous request on the adapter. The
other port types offer the other interaction patterns or styles that are available
with the adapter.
5. Set the partner link for the invoke activity. Select the activity. Then, click the
partner link icon and drag it to the STOCKINFOHubRequest. Figure 8-20
shows the results.
Figure 8-20 Set Adapter Invocation ParnerLink
Chapter 8. Integration using WebSphere Business Integration Adapters 229
Setting operation and variables for the invoke activity
Now, you set the operation (STOCKINFORetrieve) to invoke and create the
variable to hold the result:
1. Select the Implementation tab for the Invoke JDBC Adapter activity.
Figure 8-21 Invoke JDBC Adapter Implementation view
2. Verify that the operation is STOCKINFOHubRequest and set the operation to
STOCKINFORetrieve. Set the Request variable to QuoteInput and the
Response variable to QuoteOutput as shown in Figure 8-21.
3. Press Ctl+S to save the flow.
Creating data transformation snippet for the OutputVariable
Now, you create a Java snippet to do the data transformation for the
OutputVariable to provide the result that is returned to the caller of this service:
1. Create a Java Snippet activity by clicking the Java Snippet icon and then
clicking the StockInfo Flow canvas.
2. Enter Set StockQuoteInfo as the display name. (The name will be
automatically set without the spaces.)
3. Use the transaction links to have Java Snippet called between the Invoke
JDBC Adapter and Reply activities.
230 Managing Information Access to an EIS Using J2EE and Services Oriented Architecture
4. Click Implementation, and on the implementation tab, enter the code shown
in Example 8-5:
Example 8-5 Data Transformation for Output Variable
STOCKINFOResponseMessage responseMessage = getQuoteOutput();
STOCKINFOElement infoElement = responseMessage.getReturnBodyPart();
//Printing results returned from adapter
System.out.println(“Company: “ + infoElement.getCOMPANY());
System.out.println(“Stock Price: “ + infoElement.getVALUE());
System.out.println(“Symbol: “ + infoElement.getSYMBOL());
System.out.println(“Change: “ + infoElement.getCHANGE());
int trend = infoElement.getTREND();
String move = “Flat”;
if(trend == -1) {move = “Down”;}
else if(trend == 1) {move = “Up”;}
System.out.println(“Trend: “ + move);
//Set Results into Output Variable
5. Right-click in the code tab, then select Source Organize Imports to
resolve the types to set the values that are coming from the QuoteOutput to
the OutputVariable variable. For now, you print the results.
6. Press Ctrl+S to save the BPEL process.
Generating and deploying StockQuoteInfo service
Next, you generate the deploy code for the StockQuoteInfo service with an EJB
binding to expose the service through a session bean:
1. Right-click the StockQuoteInfo.bpel file and choose Enterprise Services
Generate BPEL Deploy Code.
2. Select ProcessPortType and confirm that the EJB binding is selected as
shown in Figure 8-22 on page 231. Click OK to generate the code.
..................Content has been hidden....................

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