Chapter 16. Remote Integration Objects (RIO) 499
# IBM Global Services Canada
#
use strict;
use LWP::UserAgent; # A WWW UserAgent class
use HTTP::Request::Common; # Class encapsulating HTTP
Requests
use HTTP::Cookies; # Cookie storage and management
use XML::DOM; # XML Parser library (Document
Object Model)
my ($XMLHeaderDTD, $XMLDataRequest1, $XMLDataRequest2, $CookieJar, $UserAgent,
$Response, $HostName, $AccountNum);
#----------------------------------------------------------------------------
# Check command line arguments.
$AccountNum = $ARGV [0] || die "Usage: RIOXMLAppChaining.pl AccountNumber
[HostName]\n";
$HostName = $ARGV [1] || "127.0.0.1";
#----------------------------------------------------------------------------
# Prepare XML Header.
$XMLHeaderDTD = <<END;
<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<!DOCTYPE com.ibm.HostPublisher.IntegrationObject.properties [
<!ELEMENT com.ibm.HostPublisher.IntegrationObject.properties
(inputProperties,outputProperties)>
<!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)>
]>
END
#----------------------------------------------------------------------------
# Prepare XML Input Request for the first Integration Object in the chain.
$XMLDataRequest1 = <<END;
<com.ibm.HostPublisher.IntegrationObject.properties
name="IntegrationObject.CICSChain1">
<inputProperties>
<inputProperty name="nada">
<value></value>
500 IBM WebSphere Host Publisher Version 3.5
</inputProperty> </inputProperties>
</com.ibm.HostPublisher.IntegrationObject.properties>
END
#-----------------------------------------------------------------------------
# Prepare XML Input Request for the last Integration Object in the chain.
$XMLDataRequest2 = <<END;
<com.ibm.HostPublisher.IntegrationObject.properties
name="IntegrationObject.CICSChain2">
<inputProperties>
<inputProperty name="account_num">
<value>$AccountNum</value>
</inputProperty> </inputProperties>
</com.ibm.HostPublisher.IntegrationObject.properties>
END
#----------------------------------------------------------------------------
# Create a cookie container and post the request for the first
# Remote Integration Object.
$CookieJar = HTTP::Cookies->new;
$UserAgent = new LWP::UserAgent;
$UserAgent->cookie_jar ($CookieJar);
$Response = $UserAgent->request (POST 'http://' . $HostName .
'/_IBM_HP_WebAdmin_/RIOServlet',
[hPubExecuteXML => $XMLHeaderDTD .
$XMLDataRequest1]);
$Response->is_success || die "The HTTP request to $HostName has failed
[CICSChain1]!\n";
#----------------------------------------------------------------------------
# Scan the cookies and output the Session ID.
$CookieJar->scan (\&DumpSessionID);
#----------------------------------------------------------------------------
# Post the request for the last Remote Integration Object.
$Response = $UserAgent->request (POST 'http://' . $HostName .
'/_IBM_HP_WebAdmin_/RIOServlet',
[hPubExecuteXML => $XMLHeaderDTD .
$XMLDataRequest2]);
$Response->is_success || die "The HTTP request to $HostName has failed
[CICSChain2]!\n";
Chapter 16. Remote Integration Objects (RIO) 501
#---------------------------------------------------------------------------
# Parse the XML response from the RIO and output the results.
&ParseXMLResponse ($Response->content);
#----------------------------------------------------------------------------
# End of program.
exit;
#----------------------------------------------------------------------------
# Parse the returned XML data and dump the output properties.
sub ParseXMLResponse
{
my ($Parser, $XML_DOM_Tree, $RIO_XML_Response);
$RIO_XML_Response = $_[0];
$Parser = new XML::DOM::Parser (KeepCDATA => 1, ErrorContext => 2);
$XML_DOM_Tree = $Parser->parse ($RIO_XML_Response);
foreach my $OutputProperty ($XML_DOM_Tree->getElementsByTagName
("outputProperty"))
{
print $OutputProperty->getAttribute('name') . " ===> [";
my $Property = @{$OutputProperty->getElementsByTagName ("value")} [0];
if ($Property->hasChildNodes())
{
print $Property->getFirstChild->getData()
}
print "]\n";
}
}
#----------------------------------------------------------------------------
# Output the Session ID from the HTTP::Cookie object.
sub DumpSessionID
{
if ($_[1] eq "sesessionid")
{
print "\nThe Session ID is: " . $_[2] . "\n\n";
}
}
502 IBM WebSphere Host Publisher Version 3.5
The XML sample program displays the response and the session ID used by the
Integration Object chain, as follows:
The Session ID is: H3D4BIAAAAAAWCIYNIPDPMQ
address ===> [55 WILLOW STREET, ANYTOWN, NC ]
account_num ===> [10100]
accountNum ===> [10100 ]
surname ===> [BLACK ]
firstName ===> [JOHN ]
hPubErrorOccurred ===> [0]
hPubErrorMessage ===> []
hPubErrorException ===> []

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.