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.

encoded string can be obtained by invoking the getHeader() method on the<br />

HttpServletRequest object. <strong>The</strong> encoded string must then be passed to a<br />

StringTokenizer object, and decoded using an appropriate decode method. We<br />

utilized a separate utility class, Base64, for this purpose. This supplies the<br />

decode and encode methods and is packaged with CTGTesterCCI.<br />

For further details on HTTP basic authentication and Base64 encoding, refer to<br />

the redbook Securing Web Access to <strong>CICS</strong>, SG24-5756.<br />

<strong>The</strong> user ID and password from HTTP basic authentication are sent to the JSP<br />

for output. However, they are not flowed to <strong>CICS</strong>. <strong>The</strong> code for doing this if using<br />

an unmanaged connection factory is included in the source, but commented out.<br />

<strong>The</strong> next section of code performs a JNDI lookup for our session bean, shown in<br />

Figure B-25.<br />

// lookup our session bean<br />

Context ic = new InitialContext();<br />

Object or = ic.lookup("java:comp/env/ejb/CTGTesterCCI");<br />

CTGTesterCCI tester = null;<br />

if (or != null)<br />

{<br />

CTGTesterCCIHome home = (CTGTesterCCIHome)PortableRemoteObject.narrow(or,<br />

CTGTesterCCIHome.class);<br />

tester = home.create();<br />

}<br />

Figure B-25 JNDI lookup and remote method invocation<br />

We get a JNDI InitialContext and then perform a lookup using the JNDI name<br />

java:comp/env/ejb/CTGTesterCCI. This is a local JNDI name that will be mapped<br />

to the actual JNDI name of the session bean at deploy time. To indicate we want<br />

such a mapping, we create an EJB reference in the Web deployment descriptor<br />

with the name ejb/CTGTesterCCI.<br />

Once we have looked up the object, we get the home interface of our session<br />

bean using the narrow() method call of the RMI class PortableRemoteObject.<br />

This method performs any operations necessary to allow us to invoke the bean’s<br />

create() method and returns a reference to the session bean home interface.<br />

We then call the create() method on this home interface to get a reference to the<br />

remote interface we will use to invoke our business logic.<br />

Next, we execute our business logic on the session bean and collect the results,<br />

as shown in Figure B-26 on page 364.<br />

Appendix B. Sample applications 363

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

Saved successfully!

Ooh no, something went wrong!