![[z/OS]](../images/ngzos.gif)
Using the outbound APIs with the external address space or subsystem
Use this task to create an interaction between the outbound APIs and the external address space or subsystem.
Before you begin
Procedure
Results
If your Java EE application component is participating in an RMLT or global transaction, and the application is communicating with a batch program or a CICS link server started with keyword TXN=N, the optimized local adapter connection is not able to establish a connection to the target program. The target program is not able to provide the transaction capabilities required by the Java EE application. An exception displays with minor code 0xC9C24C3B. This code indicates that the target registration name is found but is not enabled for transactions. Only CICS link servers enabled with keyword TXN=Y can support propagating transactions from WebSphere Application Server for z/OS.
Example
The following method shows how to start an interaction with input and output data as a byte array (byte[]):
public byte[] driveInteraction(javax.resource.cci.ConnectionFactory cf,
javax.resource.cci.Connection con,byte[] inputDataBytes),throws javax.resource.ResourceException
{
// Create an interaction using the optimized local adapter connection
javax.resource.cci.Interaction i = con.createInteraction();
// The InteractionSpec describes the service we want to call
com.ibm.websphere.ola.InteractionSpecImpl isi = new com.ibm.websphere.ola.InteractionSpecImpl();
isi.setServiceName("MYSERVICE");
// The input data is specified using an IndexedRecord. The first
// slot in the indexed record contains the input data bytes.
javax.resource.cci.RecordFactory rf = cf.getRecordFactory();
javax.resource.cci.IndexedRecord ir = rf.createIndexedRecord(null);
ir.add(inputDataBytes);
// The interaction returns another IndexedRecord, whose first
// slot contains the output data bytes.
javax.resource.cci.Record or = i.execute(isi, ir);
byte[] outputDataBytes = null;
if (or != null)
{
outputDataBytes = (byte[])((javax.resource.cci.IndexedRecord)or).get(0);
}
// Return the output data to the caller
return outputDataBytes;
}
The following method shows how to start an interaction using a Rational® Application Developer generated copybook Record object:
/**
* An example of driving an optimized local adapter interaction, using a Rational
* Application Developer copybook mapping class as input (inputRecord) and receiving
* a Rational Application Developer copybook mapping as output.
*/
public javax.resource.cci.Record driveInteraction(
javax.resource.cci.Connection con,
javax.resource.cci.Record inputRecord)
throws javax.resource.ResourceException
{
// Create an interaction using the OLA connection
javax.resource.cci.Interaction i = con.createInteraction();
// The InteractionSpec describes the service we want to call com.ibm.websphere.ola.InteractionSpecImpl isi =
new com.ibm.websphere.ola.InteractionSpecImpl();
isi.setServiceName("MYSERVICE");
// The Rational Application Developer generated copybook implements
// javax.resource.cci.Record and can be passed directly to the interaction.
// The interaction returns an IndexedRecord, whose first slot contains
// the output data bytes.
javax.resource.cci.Record or = i.execute(isi, inputRecord);
javax.resource.cci.Record outputRecord = null;
if (or != null)
{
// In this example, RADGeneratedOutputType is the name of the Rational Application Developer
// generated copybook mapping class.
outputRecord = new RADGeneratedOutputType();
// The output bytes are stored in the output record returned on the
// interaction, which is an IndexedRecord.
byte[] outputDataBytes =
(byte[])((javax.resource.cci.IndexedRecord)or).get(0);
// To convert the output bytes to another Rational Application Developer generated copybook,
// call the setBytes(byte[]) method of that class. The class will
// implement the com.ibm.etools.marshall.RecordBytes interface.
((com.ibm.etools.marshall.RecordBytes)outputRecord)
.setBytes(outputDataBytes);
}
// Return the output data to the caller
return outputRecord;
}