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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

364 <strong>CICS</strong> <strong>Transaction</strong> <strong>Gateway</strong> <strong>V5</strong><br />

ResultsBean resultsB = tester.execute(funcName, encoding, commareaInput,<br />

commareaLengthInt, username, password, managedBool, gatewayURL,<br />

gatewayDaemonPort, cicsServer, mirror, traceInt, iterationsInt,<br />

appTraceBool);<br />

String results = resultsB.getResultsString();<br />

// set result string attribute<br />

request.setAttribute(attrResultsString, results);<br />

// get byte data from results<br />

byte[] data = resultsB.getResultsBytes();<br />

// set result string in default encoding attribute<br />

request.setAttribute(attrDefaultResultsString, new String(data));<br />

// set request attribute for hex data<br />

request.setAttribute(attrHexResultsString, byteArrayToHex(data));<br />

Figure B-26 Executing the session bean business logic<br />

<strong>The</strong> execute() method takes all of the HTML form parameters as input and<br />

returns a ResultsBean object. This is a data bean class that encapsulates a<br />

String object and a byte array, and provides methods to get and set both. It is<br />

shown in Figure B-27 on page 365.<br />

If the session bean does not successfully complete the <strong>CICS</strong> request, then it will<br />

throw an exception, so the execute() method call is inside a try catch block.<br />

Assuming the execute() method ran successfully, we set a request attribute for<br />

the COMMAREA converted into a String in the encoding specified in the HTML<br />

form. We also set an attribute with the hexadecimal representation of the<br />

COMMAREA, to aid data conversion debugging, and an attribute with the<br />

COMMAREA converted into a String using the JVM default encoding.

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

Saved successfully!

Ooh no, something went wrong!