© Copyright International Business Machines Corporation 2003. All rights reserved.
Many companies today need to bring legacy enterprise applications to the Web. Given their limited resources, rewriting legacy applications to run on the Web is out of the question. Instead, they need to leverage their deep investment in business transactions running in tried-and-true mainframe operating environments. Rather than rewrite, companies must reuse existing transactions by exposing them as Web applications while maintaining their high performance, scalability, and reliability.
Web Application Models, a component of IBM ® VisualAge® Pacbase and a plug-in to IBM WebSphere® Studio, is a tool to accelerate this process. Web Application Models can consume enterprise services built from existing CICS® or IMSTM transactions to generate the JavaTM 2 Enterprise Edition (J2EE) middle-tier components that connect to COBOL programs running in a mainframe environment through standard J2EE Connector Architecture (JCA) and the Web Services Invocation Framework (WSIF).
This two-part article describes how to use Web Application Models along with WebSphere Studio Application Developer Integration Edition or WebSphere Studio Enterprise Developer to develop Struts-based Web applications that access existing COBOL programs running on CICS. Part 1 covers:
- Creating an enterprise service proxy for a CICS ECI program
- Generating and testing the service proxy
- Using the proxy with Web Application Models to generate the remaining middle-tier components
- Testing the web application by accessing the CICS program through a JCA resource adapter
Part 2 covers customization of the Web user interface using customized Web Application Model XSL stylesheets.
Create an enterprise service proxy for a CICS ECI COBOL program
For a complete description of creating an Enterprise Service, see the online help under Enterprise Developer Information => Building Enterprise Services. There is also a helpful "Cheat Sheet" entitled Create an enterprise service for a CICS program (CICS ECI). The next section shows how to create a service from a CICS program called TRADERBL.
Generate Web Services Description Language
Import COBOL Copy Book.
- Open Business Integration perspective.
- Create a new service project called MyServiceProj.
- Right-click on MyServiceProj and select Import => File system.
- Find the directory and the COBOL program, make sure MyServiceProj is the destination folder, and then click Finish.
Launch Service built from wizard and import resource adapter.
- Right-click on MyServiceProj and select New => Service built from.
- If the CICS ECI resource adapter is not present in the workspace, you must import it. To do so, click on Import Resource Adapter.
- Find the connector file named
<studio root>resource adapters\cicseci.rar. - In the same dialog, enter a new connector project name. See Figure 1 below.
- Click Finish.
Figure 1. Importing a CICS ECI resource adapter into a new connector project.

Figure 2. Choose CICS ECI adapter as shown below, then click Next.

Enter the connection properties for:
- Gateway address
- Port number
- CICS server name
- Username
- Password
- TPN Name
- Transaction name
- JNDI lookup name
Click Next to go to the Service Binding panel of the wizard and enter an Interface file name:
Figure 3. Service Binding panel

Clicking Finish generates three WSDL files. The default editor for MyTradeCICSECIBinding.wsdl
is automatically opened. The next step is to create a new operation for the service in the editor and define the input message for the
COBOL program:
- Under Port type and Binding Operations, click on New to create a new operation.
- Enter
getCompanyas the operation name, then click Next. - In the Operation Binding Properties, enter the Function Name
TRADERBL, which is the name of the CICS program, and click Next again to define the input message.- Click on Import and select the COBOL program in MyServiceProj, then click Next.
- In the COBOL Import Properties panel, select the z/OS® platform (or the platform on which CICS is running
, and then click Next. - In the COBOL Importer panel, select COMMAREA-BUFFER as shown below, then click Finish.
Figure 4. Select COMMAREA-BUFFER data structure.
- In the Operation Binding panel, check Use input message for output, then click Finish.
Generate CICS ECI service proxy
- Right-click on MyServiceProj/org.tempuri/MyTradeCICSECIService.wsdl and select Enterprise Services => Generate Service Proxy.
- Accept defaults for the names and click Next.
- As shown in Figure 5, select Command Bean and the getCompany operation, and then click Finish.
Figure 5. Service proxy generation

The Service Project now contains the WSDL files, the generated Service proxy, and the command bean:
Figure 6. Service project files

The generated proxy uses the Java API of the Web Services Invocation Framework (WSIF) to communicate with the CICS program. For the Web application, the proxy is seen as an enterprise service that it can execute. Before building the Web application that executes this service proxy, unit-test the enterprise service to make sure that the CICS program is correctly invoked and can send data back to the proxy.
Switch to the Java Perspective and open the class MyTradeProxy.java.
Go to the main() method and add code before and after the call to execute as shown below. I provide the user ID and the input parameters that the COBOL program expects: a request type = "Share_value" and a company name = "IBM". After the execute, we print out to the console some of the data returned by the COBOL program.
/**
* main method (for proxy unit testing)
* @generated
*/
public static void main(String[] args) {
try {
MyTradeProxy aProxy = new MyTradeProxy();
// user code begin {set_inputs}
COMMAREABUFFER comm = new COMMAREABUFFER();
comm.setUserid("F058971");
comm.setRequest__type("Share_Value");
comm.setCompany__name("IBM");
aProxy.setCOMMAREABUFFER(comm);
// user code end
aProxy.execute();
// user code begin {get_outputs}
COMMAREABUFFER result = aProxy.getCOMMAREABUFFER();
System.out.println("1=" + result.getUnit__value__1__days());
System.out.println("costbuy=" + result.getCommission__cost__buy());
System.out.println("costsell=" + result.getCommission__cost__sell());
// user code end
|
Save the class, then from the menu select Run, Run as, Java Application. The output in the Console looks like this:
1=00163.00 costbuy=010 costsell=015 |
Export service proxy as a JAR file
Select the project MyServiceProj, right click and then Export. Export as a JAR File and choose a destination directory on the file system.
Generate the Struts-based middle tier
To generate the JSPs, Java classes, and configuration files that make up the middle tier we use Web Application Models. The procedure consists of:
- launching the wizard and selecting a pattern
- selecting the data from the Service proxy that we want to use
- selecting some basic display properties
- selecting generation parameters and generation
- configure WebSphere Test Environment (WTE) and test
To launch the wizard, go to File, New, Other, Web, Model-based Web Application. As in the image below you have to choose an application name. The application name is used to identify resources that will be generated from this model.
Select the technology identified as WSIF proxy. If you choose Relational Database technology, the wizard will ask you to connect to a relational database where you can select tables that will be used to create the Web pages. The VisualAge Pacbase technology consumes VisualAge Pacbase proxies that can access numerous back-end systems.
Figure 7. Enter application name and select a technology

After clicking Next, the Select Patterns panel in Figure 8 is displayed. Browse the available patterns to get an idea of the different configurations. In this example, the COBOL program which we want to call displays a detail view of stock shares for a company.
Figure 8. Browse available patterns and their variations

The second step in the wizard is to configure the data from the Service proxy that will be used with the pattern.
- As shown in Figure 9, browse for and select the proxy JAR that was exported.
- Then under Input parameters, select the proxy and the COMMAREABUFFER class.
- Move the two input parameters that the COBOL program requires to do a read action, Request_type and Company_name from the left list to the right.
- For this program the input and the output parameters are in the same class. Select output parameter fields and move them to the right list also. The fields you select here can be displayed to the end user.
- You also have to configure the Update and Delete panels, even though in this case the read-only COBOL program can not do anything with the input.
- Click Next to go to the Define Layouts panel of the wizard.
Figure 9. Selecting the proxy and configuring the input and output fields

In the Define Layouts panel shown below you can select a cascading stylesheet, select/de-select fields and actions, and modify field and action properties. You can also get a preview of the Web page by clicking on the button with the eye image. Static HTML is generated on the fly to give you an idea of how the Web page will look. Click Next to go to the last page of the wizard.
Figure 10. Define layout properties for the Web page

The image below shows the generation page where you configure generation parameters:
- Change the name of the destination project to Company.
- You can also change the name of the Java packages into which you will generate.
- In the tree view you can change the names of the pages, views, and the data set. You can directly edit the default names by clicking on the name. As you change the names of these components, the file names in the list are also changed.
- When you are ready to generate, click on the Finish button.
Figure 11. Generate the Web application components.

In this section we will give you a brief description of the generated components, starting with the common Java classes.
Figure 12. Generated Java classes![]() |
|
Web content
Figure 13. Web content
|
|
WEB-INF
Figure 14. WEB-INF
|
|
- Open a Server perspective,
- create a new server project,
- create a new server and WebSphere version 5.0 server configuration. If you have an existing server project go ahead and put the new server and server configuration in the existing project.
- Ensure the resource adapter is declared in the server configuration by opening the server configuration file and going to the J2C tab of the default editor as is shown in the figure below.
- Click on the Add button and select the CICS ECI resource adapter that was imported into the workspace earlier.
- Close and save the server configuration file.
Figure 15. J2C options

- Select the Company Web Project, bring up the contextual menu and click on Run on Server.
- In the dialog box that displays, click on the Advanced button to select the new server that is now properly configured with the CICS ECI resource adapter.
- Clicking Finish will Publish the Web application to the application server, then start the application server and the application. The Web browser will be launched and the test page displayed as shown in the figure below.
Figure 16. Test page.

Figure 17. Browse the generated technical documentation

From the test page click on the link that launches the application and the detail page as shown below.
Figure 18. Launching the application opens a session and displays the input fields.

- Enter the input parameters Share_Value and IBM.
- Click the Read button to call the servlet and the CICS program.
- The CICS program sends back the information in the figure below.
Figure 19. Results returned from the CICS program

Part 1 of this article took you through the steps to create a Struts-based Web application that connects to an existing CICS program using a Java Connection Architecture resource adapter. First we used wizards in Application Developer to create an enterprise service. We imported the data description from a COBOL program to create the Web Services Description Language (WSDL). After configuring the connection parameters, we used the WSDL to generate a Java proxy and tested it to ensure we can send and receive data from the CICS program.
We packaged the proxy in a jar and used the jar as an input to the Web Application Models wizard. In the wizard we selected the fields to display and configured some basic presentation properties before generating the Struts Java classes and JSPs that communicate with the CICS proxy. We then configured the server and deployed, launched and tested the application.
The generated application conforms to the J2EE standard and can be deployed to an application server which can provide the reliability, scalability, and required performance. And although it has basic validation, error handling, accesses and displays data and takes care of other such mundane but necessary functions, it doesn't do a whole lot. What about more complex validation? What about business rules? What about integration with other Web pages? Security considerations? Where in the generated code do all of these specifics get implemented? The application doesn't look particularly attractive either.
Part of the answer to these questions is provided by generated code that is clear, well-documented, easily understandable and meant to be modified to handle the above functions. Web Application Models is not meant to produce out-of-the- box, ready-to-run applications, but rather, produce the basic building blocks which you can rearrange and use to construct real- world deployable applications.
Part 2 of this article addresses the task of providing a user interface that is ready for deployment. I will show you how Web Application Models uses Extensible Stylesheet Language Transformations (XSLT) at development time to incorporate common look and feel into the application.

Kevin Griffith is an IBM Certified IT Specialist at the IBM Paris Software Lab. He specializes in IBM rapid application development tools such as VisualAge Generator Templates and Web Application Models, and helps customers worldwide improve their application development productivity. He is a graduate of the U.S. Military Academy at West Point, has a masters degree in civil engineering from Massachusetts Institute of Technology, and is a registered, but non-practicing Professional Engineer just for fun. You can reach Kevin at griffith.k@fr.ibm.com .





