Chapter 2. Financial services business scenario 273
Figure 2-275 Test SCA binding 3/6
274 SOA Solutions Using IBM Information Server
Figure 2-276 Test SCA binding 4/6
Figure 2-277 Test SCA binding 5/6
Chapter 2. Financial services business scenario 275
Figure 2-278 Test SCA binding 6/6
Test JMS binding
Testing a WID generated service with JMS bindings requires user-written code.
After the A2ZSCA_Brokerage module is deployed as described in “Step 4g:
Deploy the SCA module” on page 205, we need to develop a client application to
access the deployed service. Example 2-9 on page 276 shows the client code
we developed to invoke the OpenAccountJMS service with JMS binding. It
includes the following coding:
򐂰 Context for looking up JMS connection factory and queue —
( and
PROVIDER_URL (iiop://lead:2809)
򐂰 writeOpenAccount (Map m) looks up the JNDI name (jms/MQCFLead)
connection factory, and the specific queue (jms/Q1lead) to which it sends a
message with the open account information from the Map m.
Note: As mentioned earlier, it sets the JMSCorrelationID to the social
security number field ssnumb.
276 SOA Solutions Using IBM Information Server
򐂰 readOpenAccount () looks up the JNDI name (jms/MQCFLead) connection
factory, and the specific queue (jms/Q2lead). It listens on this queue, and
reads a message and writes its contents to a HashMap and also prints it
The code writes a JMS message to open an account for “John Doe”
with social security number of “111-11-1111” and other details which are hard
coded in the program since this is just test code. It then waits on a response and
prints the received message.
Figure 2-279 on page 280 through Figure 2-284 on page 285 describe the test
using the RAD tool. Select in the a2z package, and then from the
Run menu, select Run As and Java Application as shown in Figure 2-279 on
page 280. The results of this execution are shown in Figure 2-280 on page 281,
which prints the message written to the message queue and puts up the prompt
“Press key to continue”.
There is a human task interaction (RunCheck) in the OpenAccountProcess
which approves or disapproves the request as shown in Figure 2-281 on
page 282. The RunCheck task creates a task in the Human Task Manager
component of WebSphere Process Server. For testing purposes, you cam use
BPC Explorer to view all current tasks, claim a task, and complete it as shown in
Figure 2-283 on page 284.
Figure 2-282 on page 283 through Figure 2-284 on page 285 show the use of
Business Process Choreographer Explorer to put a message false (indicating a
disapproval by a human of this open account request) in the canCreateAccount
field as shown in Figure 2-284 on page 285. This puts a message in the JMS
message queue. The user then presses a key to continue, which causes MQTest
to consume this message and put out a message saying that an account cannot
be created as shown in Figure 2-284 on page 285. This concludes a successful
test of the WID generated service with JMS binding.
Example 2-9
package a2z;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
import javax.jms.MapMessage;
import javax.jms.Message;
import javax.jms.Queue;
import javax.jms.QueueConnection;
import javax.jms.QueueConnectionFactory;
Chapter 2. Financial services business scenario 277
import javax.jms.QueueReceiver;
import javax.jms.QueueSender;
import javax.jms.QueueSession;
import javax.jms.Session;
import javax.naming.Context;
import javax.naming.InitialContext;
public class MQTest {
* get a Context object for looking up JMS connection factories
* and queue
static Context getContext() throws Exception {
// create context for remote server where the JMS Queues are defined
Properties props = new Properties();
props.put(Context.PROVIDER_URL, "iiop://lead:2809");
Context context = new InitialContext(props);
return context;
* write the key-value pairs of the input as a
* JMS MapMessage
public void writeOpenAccount(Map m) throws Exception {
// lookup Queue
Context ctx = getContext();
Object o = ctx.lookup("jms/MQCFLead");
QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory) o;
o = ctx.lookup("jms/Q1lead");
Queue queue = (Queue) o;
// use standard JMS API to create message
QueueConnection queueConnection = queueConnectionFactory.createQueueConnection();
QueueSession session = queueConnection.createQueueSession(false,
QueueSender sender = session.createSender(queue);
MapMessage message = session.createMapMessage();
// use SSNumber as correlation ID
message.setJMSCorrelationID((String) m.get("ssnumb"));
// the "TargetFunctionName" property is used by the MQ JMS binding
// use the name as indicated in the "native method" field
// of the "Method binding" tab
message.setStringProperty("TargetFunctionName", "openAccount");
// prepare MapMessage
Iterator it = m.entrySet().iterator();
while (it.hasNext()) {
Map.Entry entry = (Map.Entry);
Object value = entry.getValue();
message.setObject((String) entry.getKey(), value);

Get SOA Solutions Using IBM Information Server now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.