Editor's note: Know a lot about this topic? Want to share your expertise? Participate in the IBM Lotus software wiki program today.
| IBM Mashup Center wiki |
|---|
A lot of enterprise information exists in mainframe applications that are currently accessed using 3270 or 5250 consoles. If this mainframe data could be available in a format that allows it to be easily combined with other data, either within the enterprise or available on the Internet, business users could have the ability to harness this data to help solve business issues using a feature-rich, modern browser interface. In this article, we describe a use case in which valuable financial information is "locked up" in a 3270 data application and a loan officer wants to extract that data to create a new Web-based mashup application. A mashup is a lightweight Web application created by combining information or capabilities from more than one existing source to deliver new functions and insights. The useful parts of green-screen (3270) applications can be isolated, wrapped, and then used in a mashup framework to provide new insights to the business user.
First, the content in mainframes must be formatted as data feeds before it can be consumed by a mashup framework. This article provides a step-by-step guide to generating Atom feeds for mainframe content using Rational® Host Access Transformation Services (HATS). The developerWorks® article, "Use HATS to generate Atom feeds for mainframe applications," written by Ramakrishnan Kannan, Prasad Nagaraj, and Saikrishna Vaidyanathan, presents how to create Atom feeds from 3270 data. This article extends their concept by providing another example and by creating a situational Web application using IBM Mashup Center.
A financial services loan officer for a bank has data that she needs to access to determine if a current bank account holder can obtain a new car loan. In a green-screen 3270 mainframe application, the loan officer is able to find out current account balances for account holders. She then has to use a Web application to obtain the account holder’s credit score. Another application allows her to determine the number of car theft reports in the geographic area of the loan applicant. Currently, the loan analyst has to switch to three different computer applications to access information that she needs to determine if the account holder is eligible for a new car loan. This article primarily focuses on extracting data from the 3270 application. The credit score and car theft reports for a geographic area are assumed to have been already turned into data feeds by IBM Mashup Center feed generator or are already accessible using a Web browser.
Account balance information is currently accessed through a 3270 application as shown in figure 1.
Figure 1. 3270 application data
Using IBM Rational Host Access Transformation Services (HATS), you can create an Atom data feed. This data feed is then combined with other data to create a composite dashboard application, shown in figure 2, for the loan officer.
Figure 2. Composite dashboard application
Here are a step-by-step guide and code template examples that you can use to extract 3270 application data and place it in a mashup application.
Create a new Rational Host Access Transformation Services (HATS) project with default settings. Follow these steps:
- Enter the host name in the Connections Settings window. All other fields are filled in by default; modify if necessary. Click Finish. Figure 3 shows one set of connection settings; your settings might be different.
Figure 3. HATS Create a Connection window
Record a macro to query for information by doing the following:
- Right-click your main connection, and click Open HATS Host Terminal and then main.
You should see the 3270 screen shown in figure 4.
Figure 4. 3270 Logon screen within HATS host terminal environment
- Click the Record button at the top of the screen, and give your macro a name.
- Step through the process that you want to use, and select the lines that you want to extract on each page by clicking the Add Extract Action button. See figure 5.
Figure 5. Selection area to extract 3270 data
- Select the Extraction Format option Extract this region as a list of strings for each extract action so that each line is a different entry in a list later. All other values are set by default. Click Finish.
Figure 6. Edit Extract window
Create an Integration Object from the macro by following these steps:
- Right-click your macro and select the Create Integration Object option.
- Open the new Java™ source under Integration Object; it has the same name as the macro. (See the sample code in listing A-1 in the appendix of this article.)
- Note the defined HAOVariables near the top. Change the last argument in each of their instantiations from HAO_VARIABLE_SIMPLE to HAO_VARIABLE_ARRAY. This change allows you to get the array of extracted lines instead of a single string that combines the lines. Change the arguments as follows:
- From:
HAOVariable inquiry1 =
new HAOVariable("","inquiry1","inquiry1",false,"",0,0,63,7,HAO_VARIABLE_SIMPLE); - To:
HAOVariable inquiry1 =
new HAOVariable("","inquiry1","inquiry1",false,"",0,0,63,7,HAO_VARIABLE_ARRAY);
- From:
- Now add a Getter of type vector for each inquiry that returns your_inquiry.oMultiValues. For example, see the code in listing 1.
Listing 1. Example of Getter for the inquiry result array
public Vector getInquiry1AsVector()
{
hPubErrorOccurred = 0;
if (HPubTracingOn) { Ras.trace( className, "getInquiry1 array: ",
inquiry1.stringValue); }
return (inquiry1.oMultiValues);
}
|
Next, create Model 1 Web pages from your Integration Object by right-clicking your integration object and selecting the Create Model 1 Web Pages option. See figure 7.
Figure 7. Create Model 1 Web Pages window
Use the default settings that are given and click Finish to create a JSP page under Model 1 Pages.
Next, alter the JSP page to output the Atom feed. Follow these steps:
- You now have a JSP page under Web Content - Model 1 Pages; double-click it to go to the source.
- Using the provided JSP file, InquiryMacroOutput.jsp (shown in listing A-2 in the appendix of this article) as a guide, replace the JSP code with your own that outputs an Atom feed. Disregard the warnings about parameterizing the ArrayList because JSP does not handle parameterization.
Test the JSP page by going to its endpoint and looking at the Atom feed.
If you use the Microsoft® Internet Explorer browser, your page should like the text in figure 8.
Figure 8. Resulting Atom feed from the JSP page
To add the new Atom feed to IBM InfoSphere™ MashupHub, follow these steps:
- Open InfoSphere MashupHub and click the New Feed under the Create section of the MashupHub Homepage.
- Select Existing RSS or Atom Feed (Registration) under departmental in the list that displays as shown in figure 9. Click Next.
Figure 9. New feed creation panel within IBM Mashup Center
- Enter the URL of the JSP page that you created, and then click Next. See figure 10.
Figure 10. Specify Atom feed URL within MashupHub feed creation window
- Give the new feed a Title and Description and any tags that you want associated with the feed, and then click Finish.
- The feed has now been saved in the InfoSphere MashupHub Catalog. You can add it to IBM Lotus Mashups by selecting the Add to Lotus Mashups option.
- Enter the location of your Lotus Mashups server, and then click Next.
- Optionally, change the Title, Description, Category or Feed Viewer options, and then click Finish.
Build a mashup in Lotus Mashups using your feed
Follow these steps to build a mashup in Lotus Mashups using your feed:
- Open Lotus Mashups and optionally open a new page for your mashup.
- Click the Go to Edit button to begin building your mashup.
- Select your feed from the toolbar; by default displays in the Collaboration option in the toolbar as shown in figure 11. Drag the feed onto the page. Resize it if necessary.
Figure 11. Data viewer widget within Mashup Center showing Atom feed of 3270 data
- Click the Favorites option on the toolbar, and add OpenStreetMap and any other widgets that you want to use in your mashup application. For our example, there are feeds that supply Credit Report History and Car Theft Reports for a given geographical area. The OpenStreetMap and Website Displayer widgets are used. Wire the elements from the 3270 data table to these new widgets to create a customized application to address your business needs.
- When an item is clicked in the feed you should see the corresponding car theft information on the map and the credit report information in the Website Displayer widget as shown in figure 12.
Figure 12. Completed Loan officer dashboard mashup application
IBM Mashup Center and Rational Host Access Transformation Services can let you leverage data that is currently locked up in 3270 or 5250 applications and use the data for other Web-based applications. This article provides a step-by-step guide on how to extract 3270 data and create a new situational mashup application. Code templates are supplied that you can tailor to extract data from a variety of 3270 applications.
Listing A-1. Code for the integration object (InquiryMacro.java)
import java.util.Vector;
import com.ibm.HostPublisher.IntegrationObject.*;
import com.ibm.HostPublisher.Server.Ras;
public class InquiryMacro extends HPubHODCommon
{
public static float getIOTemplateVersion()
{ return 7.0F; } // Template version - HATS 7.0
public static String getIOTemplateType()
{ return "-DEFAULT"; } // Template type - Host Default
public static String getIOVersionInfo()
{ return "(IBM)"; } // Version info - IBM supplied
public static String getIOTemplateRevision()
{ return ":1.1"; } // Template revision per version - internal value
public String hPubIOVersion= getIOBaseVersion()+";"+getHPubBeanType()+
getIOTemplateType()+getIOTemplateVersion()+
getIOTemplateRevision()+getIOVersionInfo();
public String getIOVersion() { return hPubIOVersion; }
// Generated Objects altered to export their data as
//HAO_VARIABLE_ARRAY instead of HAO_VARIABLE_SIMPLE
HAOVariable inquiry1 =
new HAOVariable("","inquiry1","inquiry1",false,"",0,0,63,7,HAO_VARIABLE_ARRAY);
HAOVariable inquiry2 =
new HAOVariable("","inquiry2","inquiry2",false,"",0,0,63,7,HAO_VARIABLE_ARRAY);
HAOVariable inquiry3 =
new HAOVariable("","inquiry3","inquiry3",false,"",0,0,63,7,HAO_VARIABLE_ARRAY);
HAOVariable inquiry4 =
new HAOVariable("","inquiry4","inquiry4",false,"",0,0,63,7,HAO_VARIABLE_ARRAY);
HAOVariable inquiry5 =
new HAOVariable("","inquiry5","inquiry5",false,"",0,0,63,7,HAO_VARIABLE_ARRAY);
****************************************************
******** Automatically Generated Code Not Shown ********
****************************************************
/* Added Getters to return the inquiries as a Vector */
public Vector getInquiry1AsVector()
{
return (inquiry1.oMultiValues);
}
public Vector getInquiry2AsVector()
{
return (inquiry2.oMultiValues);
}
public Vector getInquiry3AsVector()
{
return (inquiry3.oMultiValues);
}
public Vector getInquiry4AsVector()
{
return (inquiry4.oMultiValues);
}
public Vector getInquiry5AsVector()
{
return (inquiry5.oMultiValues);
}
|
Listing A-2. Code for JSP that creates the Atom feed (InquiryMacroOutput.jsp)
<%@ page contentType="text/html;charset=UTF-8"errorPage="../BasicIOErrorPage.jsp"%>
<%@ page import="com.ibm.hats.runtime.*,
javax.xml.parsers.DocumentBuilder,
javax.xml.parsers.DocumentBuilderFactory,
javax.xml.transform.OutputKeys,
javax.xml.transform.Transformer,
javax.xml.transform.TransformerFactory,
javax.xml.transform.dom.DOMSource,
javax.xml.transform.stream.StreamResult,
org.w3c.dom.Document,org.w3c.dom.Element,
org.w3c.dom.Text,
java.io.StringWriter,
java.util.ArrayList,
java.util.Vector,
java.util.Date"%>
<%@ taglib uri="hats.tld" prefix="HATS"%>
<% IOGV.process(request); %>
<jsp:useBean id="InquiryMacro" type="IntegrationObject.InquiryMacro"
class="IntegrationObject.InquiryMacro" scope="request">
<jsp:setProperty name="InquiryMacro" property="*" />
</jsp:useBean>
<%
//Use the Integration Object that is instantiated above
//to get data from the 3270 machine.
InquiryMacro.doHPTransaction(request, response);
try {
// Build the feed to return from the page here.
// A well-formed Atom Feed should contain the
// following: A root "feed" element with "title",
// "updated", "author" (containing "name" and "email"), and "id"
// Create new feed factory
DocumentBuilderFactory feedFactory = DocumentBuilderFactory.newInstance();
// Create a new feed builder from the feedFactory
DocumentBuilder feedBuilder = feedFactory.newDocumentBuilder();
// Create a new document from the feed builder
Document doc = feedBuilder.newDocument();
// Create the root "feed" Element for the Atom Feed
Element root = doc.createElementNS(
"http://www.w3.org/2005/Atom", "feed");
doc.appendChild(root);
// Create the "title" element for the Atom Feed
Element title = doc.createElement("title");
// Append the title to the root element
root.appendChild(title);
// Create a text node for the title element
Text titleText = doc.createTextNode("Sample Feed from HATS");
// Append the text to the title node
title.appendChild(titleText);
// Create the "updated" element for the root of the Atom Feed
Element updated = doc.createElement("updated");
root.appendChild(updated);
Text updateText = doc.createTextNode(new Date().toString());
updated.appendChild(updateText);
// Create the "author" element for the root of the Atom Feed
Element author = doc.createElement("author");
// Created the "name" element for under the author element
Element name = doc.createElement("name");
// Create the "email" element for under the author element
Element email = doc.createElement("email");
name.setTextContent("IBM Hats");
email.setTextContent("ibm@us.ibm.com");
// Append the name and email to the author
author.appendChild(name);
author.appendChild(email);
// Append the author element to the root
root.appendChild(author);
// Create the "id" element for the root of the Atom Feed
Element id = doc.createElement("id");
id.setTextContent("http://www.ibm.com/root");
root.appendChild(id);
// Add all of the inquiries to an array to loop through
// and construct the body of the Atom Feed
ArrayList inqueries = new ArrayList();
inqueries.add(InquiryMacro.getInquiry1AsVector());
inqueries.add(InquiryMacro.getInquiry2AsVector());
inqueries.add(InquiryMacro.getInquiry3AsVector());
inqueries.add(InquiryMacro.getInquiry4AsVector());
inqueries.add(InquiryMacro.getInquiry5AsVector());
// Create multiple "entry" elements from the inquiries
// and add them to the root "feed"
// A well-formed entry element should contain title,
// link, id, updated, and content
for (int i = 0; i < 5; i++) {
// Get the vector of strings from the array JSP can't
// have parameterized types so it must be generic
Vector inquiry = (Vector) inqueries.get(i);
// Create the top element for the new Entry
Element entry = doc.createElement("entry");
// Append the entry to the root "feed" element
root.appendChild(entry);
//Create and append the title element to the Entry
Element titleEntry = doc.createElement("title");
titleEntry.setTextContent("Entry #" + i);
entry.appendChild(titleEntry);
//Create and append the link element to the Entry
Element link = doc.createElement("link");
link.setAttribute("href", "http://www.ibm.com");
entry.appendChild(link);
//Create and append the id element to the Entry
id = doc.createElement("id");
id.setTextContent("http://www.ibm.com/id" + i);
entry.appendChild(id);
//Create and append the updated element to the Entry
Element updatedEntry = doc.createElement("updated");
entry.appendChild(updatedEntry);
Text updateEntryText = doc.createTextNode(new Date()
.toString());
updatedEntry.appendChild(updateEntryText);
Element summaryEntry = doc.createElement("content");
//******* If you plan on having html content here, you should set
//******* the type attribute to html so it will display correctly
//******* by uncommenting the following lines
//summaryEntry.setAttribute("type", "html");
//summaryEntry.setAttribute("mode", "escaped");
// Create and append any data nodes from your inquiry to
// the content node of the entry
Element record = doc.createElement("Number");
record.setTextContent(inquiry.get(0).toString().trim());
summaryEntry.appendChild(record);
Element uname = doc.createElement("Name");
uname.setTextContent(inquiry.get(1).toString().trim());
summaryEntry.appendChild(uname);
Element address = doc.createElement("Address");
address.setTextContent(inquiry.get(2).toString().trim());
summaryEntry.appendChild(address);
Element phone = doc.createElement("Phone");
phone.setTextContent(inquiry.get(3).toString().trim());
summaryEntry.appendChild(phone);
Element date = doc.createElement("Date");
date.setTextContent(inquiry.get(4).toString().trim());
summaryEntry.appendChild(date);
Element amount = doc.createElement("Amount");
amount.setTextContent(inquiry.get(5).toString().trim());
summaryEntry.appendChild(amount);
Element comment = doc.createElement("Comment");
comment.setTextContent(inquiry.get(6).toString().trim());
summaryEntry.appendChild(comment);
// Append the content element to the entry element
entry.appendChild(summaryEntry);
}
// The following block transforms the Feed into a consumable
// string for the out.print
TransformerFactory feedTransformerFactory = TransformerFactory.newInstance();
Transformer feedTransformer = feedTransformerFactory.newTransformer();
feedTransformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
feedTransformer.setOutputProperty(OutputKeys.INDENT, "yes");
StringWriter sw = new StringWriter();
StreamResult result = new StreamResult(sw);
DOMSource source = new DOMSource(doc);
feedTransformer.transform(source, result);
//Print out the constructed feed xml as the content of the page
out.print(sw.toString());
} catch (Exception e) {
System.out.println(e);
}
%>
|
Learn
-
Read the developerWorks article, “Use HATS to generate Atom feeds for mainframe applications,” written by Ramakrishnan Kannan, Prasad Nagaraj, and Saikrishna Vaidyanathan. This article presents a good foundation on how to create Atom feeds from 3270 data.
-
Learn more about Rational Host Access Transformation Services (HATS). With HATS, you can extend your 3270 and 5250 host applications to the Web, to a portlet, to a rich client, or to browsers on mobile devices quickly, easily, and with low risk. There is a trial version that you can download.
-
Take the tutorial, Creating a Web Service using HATS. This lab teaches you how to use HATS to create a Web service that exposes logic contained in a System i 5250 green screen application. This lab shows new features in V7.1, including the new Visual Macro Editor tooling.
-
Refer to the HATS Help Documentation. Read a complete overview of HATS.
-
Learn more about IBM Mashup Center. Find an easy to use business mashup solution, supporting line of business assembly of dynamic situational applications — with the management, security, and governance capabilities IT requires. A free trial download is available for developers.
-
Read the Mashup Center wiki, which contains articles on installing, administering, deploying, and using IBM Mashup Center, including tutorials for new users.
-
Watch the video that complements this article.
Get products and technologies
-
Download a trial version of IBM Mashup Center by using the online trial version located at the IBM Lotus Greenhouse Web site.
Discuss
- Participate in the discussion forum.
-
Connect with the HATS HotSpot Community. Connect with the HATS community to learn what’s new, share hints and tips, reach out when you’re stuck, and engage in dialogue with the HATS team on what you like, don’t like, and what you need.
John Feller is the manager of the IBM Emerging Technologies Toolkit Development team. He manages a creative and energetic team of developers that architect, design, and develop innovative solutions that are then made available on alphaWorks. He is currently investigating best practices to build online communities using Web 2.0 technologies like wikis, blogs, tagging, and Ajax user interfaces. He earned a bachelor's degree in computer science at the University of Dayton and a master's degree in computer and information science at Ohio State University. He received an MBA from the University of North Carolina, Chapel Hill, and is certified as a Project Manager Professional with the Project Management Institute.
Comments (Undergoing maintenance)





