Chapter 16. Remote Integration Objects (RIO) 483
In order for a client XML application to use this feature, it will require HTTP
access to the RIOServlet and an XML parser to process. Here are the semantics
for this type of application to use RIO:
1. The request to the RIOServlet is assembled into an XML document (as
specified by the RIO DTD).
2. The application opens an HTTP connection, using either the GET or POST
methods, and submits the XML request to the RIOServlet.
3. The RIOServlet executes the database or host Integration Object and returns
the results in XML format to the application.
4. The application parses the returned XML data, and now has access to the
Integration Object output properties (response).
16.7.1 Sample XML application in Java
In this section we provide an XML application sample program written in Java.
Note: The API for this interface is not provided by Host Publisher.
Client application requirements
For XML applications using Java, the application requires that the java.net.*
packages be installed and also requires the use of an XML parser, such as the
IBM XML Parser for Java (XML4J). Information about this package can be found
at the following Web site:
http://www.alphaworks.ibm.com/tech/xml4j
Secure connections
If you are planning to secure the connection between your XML application and
the Web server by using Secure Sockets Layer (SSL), you would need to use the
HTTPS protocol on the client application to connect to the RIOServlet. In order to
support this on the client side, you will need a package that provides SSL
support, such as the Java Secure Socket Extension (JSSE) from Sun
Microsystems. The sample application has commented out lines which show an
example of this use. Information about the JSSE can be found at the following
URL:
http://developer.java.sun.com/developer/earlyAccess/jsse/index.html
484 IBM WebSphere Host Publisher Version 3.5
Sample source code
The sample XML application in Java (source code) is shown here.
//----------------------------------------------------------------------------
// Host Publisher 3.5 - RIO XML Application for Sample CICS Transaction
// using a single Integration Object (no chaining)
//----------------------------------------------------------------------------
//
// Author: Roy Froehlich, royf@ca.ibm.com,
// Created: October 2000
// IBM Global Services Canada
//
import org.apache.xerces.parsers.DOMParser;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.w3c.dom.Element;
import org.xml.sax.InputSource;
import java.net.*;
import java.io.*;
//import javax.net.ssl.*;
public class RIOXMLApp
{
static public void main (String args[]) throws Exception
{
String HostName;
//---------------------------------------------------------------------------
// Check command line arguments.
if (args.length == 0)
{
System.err.println ("Usage: RIOXMLApp AccountNumber [HostName]");
System.exit (1);
}
if (args.length == 2) { HostName = args [1]; }
else { HostName = "127.0.0.1"; }
//---------------------------------------------------------------------------
// Prepare XML Header.
String XMLHeaderDTD =
"<?xml version=\"1.0\" encoding=\"ISO-8859-1\" standalone=\"yes\"?>" +
" <!DOCTYPE com.ibm.HostPublisher.IntegrationObject.properties [" +
" <!ELEMENT com.ibm.HostPublisher.IntegrationObject.properties
(inputProperties,outputProperties)>" +
Chapter 16. Remote Integration Objects (RIO) 485
" <!ATTLIST com.ibm.HostPublisher.IntegrationObject.properties name
CDATA \"\">" +
" <!ELEMENT inputProperties (inputProperty*)>" +
" <!ELEMENT inputProperty (value)>" +
" <!ATTLIST inputProperty name CDATA \"\">" +
" <!ELEMENT outputProperties (outputProperty*)>" +
" <!ELEMENT outputProperty (value+)>" +
" <!ATTLIST outputProperty name CDATA \"\">" +
" <!ELEMENT value (#PCDATA)>" +
"]>";
//---------------------------------------------------------------------------
// Prepare XML Input Request for the Remote Integration Object.
String XMLDataRequest =
"<com.ibm.HostPublisher.IntegrationObject.properties
name=\"IntegrationObject.CICS\">" +
" <inputProperties>" +
" <inputProperty name=\"account_num\">" +
" <value>" + args [0] + "</value>" +
" </inputProperty> </inputProperties>" +
"</com.ibm.HostPublisher.IntegrationObject.properties>";
//----------------------------------------------------------------------------
// Post the request for the Remote Integration Object.
//System.setProperty ("java.protocol.handler.pkgs",
"com.sun.net.ssl.internal.www.protocol");
URL servletCall = new URL ("http", HostName, 80,
"/_IBM_HP_WebAdmin_/RIOServlet");
URLConnection connection = servletCall.openConnection();
connection.setDoOutput (true);
connection.setRequestProperty
("Content-Type","application/x-www-form-urlencoded");
BufferedWriter output = new BufferedWriter (new OutputStreamWriter
(connection.getOutputStream()));
String postString = "hPubExecuteXML=" + URLEncoder.encode (XMLHeaderDTD +
XMLDataRequest);
output.write (postString);
output.flush();
output.close();
//----------------------------------------------------------------------------
// Read the response from the RIO servlet.
486 IBM WebSphere Host Publisher Version 3.5
BufferedReader in = new BufferedReader (new InputStreamReader
(connection.getInputStream()));
String RIOResponse = "";
String inputLine;
while ((inputLine = in.readLine()) != null)
{
RIOResponse += inputLine;
}
in.close();
//---------------------------------------------------------------------------
// Parse the XML response from the RIO and output the results.
ParseXMLResponse (RIOResponse);
}
private static void ParseXMLResponse (String RIO_XML_Response)
{
Document XML_DOM_Tree;
DOMParser myParser = new DOMParser();
try
{
myParser.parse (new InputSource (new StringReader
(RIO_XML_Response)));
}
catch (Exception ex)
{
System.err.println ("[Operation Terminated] " + ex);
}
XML_DOM_Tree = myParser.getDocument();
if (XML_DOM_Tree != null)
{
NodeList OutputProperties = XML_DOM_Tree.getElementsByTagName
("outputProperty");
System.out.println();
for (int Count = 0; Count < OutputProperties.getLength(); Count++)
{
System.out.print (((Element) OutputProperties.item
(Count)).getAttribute ("name"));
System.out.print (" ===> [");

Get A Comprehensive Guide to IBM WebSphere Host Publisher Version 3.5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.