01.01.2013 Views

CICS Transaction Gateway V5 The WebSphere ... - IBM Redbooks

CICS Transaction Gateway V5 The WebSphere ... - IBM Redbooks

CICS Transaction Gateway V5 The WebSphere ... - IBM Redbooks

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

create a record for use<br />

jsr = new JavaStringRecord(encoding);<br />

// set input data if we have any<br />

if (commareaLength > 0)<br />

{<br />

jsr.setText(commarea);<br />

}<br />

// make the call<br />

try<br />

{<br />

eciInt.execute(eSpec, jsr, jsr);<br />

}<br />

catch (ResourceException e)<br />

{<br />

// output the stacktrace and re-throw it back to the client<br />

e.printStackTrace();<br />

dropConnection();<br />

throw e;<br />

}<br />

Figure B-36 Executing an ECI request<br />

We create a JavaStringRecord object to encapsulate the COMMAREA data,<br />

both input and output, and set our input data. We then use the Interaction we<br />

got from the connection factory to execute the request by calling its execute()<br />

method. We pass the ECIInteractionSpec object eSpec, and the<br />

JavaStringRecord object jsr as input and output. If an exception occurs in the<br />

Interaction execute() method, we catch it, print the stack trace to the<br />

application server, drop our <strong>CICS</strong> connection, and rethrow the exception back to<br />

the remote client.<br />

Finally, we close our <strong>CICS</strong> connection, and create and set our response<br />

ResultsBean object, as shown in Figure B-37. We use the text and the byte array<br />

from the JavaStringRecord and return the ResultsBean.<br />

dropConnection();<br />

// return the commarea from the last executed program<br />

ResultsBean resultsB = new ResultsBean();<br />

resultsB.setResultsString(jsr.getText());<br />

resultsB.setResultsBytes(jsr.getData());<br />

return resultsB;<br />

Figure B-37 Returning the results<br />

Appendix B. Sample applications 371

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!