... ... sub getSASchema { my ($config, $lwp) = @_; my $saSchemaUrl = "https://" . $config->{saserver} . ":" . $config->{saport} . "/serverautomation/SA-REST.xsd"; my $sareq = HTTP::Request->new( GET => $saSchemaUrl ); $sareq->authorization_basic($config->{besuser}, $config->{bespassword}); my $xsd = $lwp->request($sareq); my $schema = XML::Compile::Schema->new($xsd->{_content}); return $schema; } ## Handle querying the Server Automation API. sub saQuery { my ($config, $lwp, $schema) = @_; my $saPlanUrl = "https://" . $config->{saserver} . ":" . $config->{saport} . "/serverautomation" . $config->{saplanurl}; my $sareq = HTTP::Request->new( GET => $saPlanUrl ); $sareq->authorization_basic($config->{besuser}, $config->{bespassword}); my $xml = $lwp->request($sareq); my $planreader = $schema->compile( READER => "{http://iemfsa.tivoli.ibm.com/REST}sa-rest"); my $xmltxt = $xml->{_content}; my $tree = $planreader->($xmltxt); return $tree; } ... ... # Down in my main. $config is a hash containing config # data parsed from a file, and $lwp is an instance of # LWP::UserAgent my $saSchema = getSASchema($config, $lwp); ## Fetch the "raw" automation plan from the BigFix SA server my $doc = saQuery($config, $lwp, $saSchema); my $basenode = $doc->{_}; print Dumper($doc); print Dumper($basenode);