querying Tivoli Workload Scheduler 8.5 (tws) using web services

Pubblico un esempio di client per l’interrogazione di tws mediante web services utilizzando perl…

#!/bin/perl

#ppm install SOAP::Lite
#ppm install Crypt::SSLeay

use SOAP::Lite
#trace=>’all’
;

#use SOAP::Lite +trace => [qw(method fault headers result debug)];

my $username = ‘user’;
my $password = ‘pass’;
my $host     = ‘host’;

sub SOAP::Transport::HTTP::Client::get_basic_credentials {
return $username => $password;
}

$wsdl = “https://$host:31116/PlanServicesWeb/services/SchedulingFactory/wsdl/SchedulingFactory.wsdl”;

#$service = “https://$host:31116/PlanServicesWeb/services/JobStreamService”;
#$service = “https://$host:31116/PlanServicesWeb/services/JobService”;

$service = “https://$host:31116/PlanServicesWeb/services/SchedulingFactory”;

$ns1 = “http://services.ws.tws.ibm.com/TWS-Scheduling”;
$ns2 = “http://types.ws.tws.ibm.com/TWS-Types”;

my $soap = SOAP::Lite->new( proxy => $service );
$soap->readable(1);
$soap->ns($ns2,’ns2′);
$soap->ns($ns1,’ns1′);

my $result=$soap->call(“queryJobs”,
SOAP::Data->name(“engineName” => undef )->prefix(ns1),
SOAP::Data->name(“filter” => \SOAP::Data->value(
SOAP::Data->name(“details”)->prefix(ns2),
SOAP::Data->name(“minimum”)->prefix(ns2),
SOAP::Data->name(“maximum”)->prefix(ns2),
SOAP::Data->name(“dataType”=>”WORKSTATION_NAME”)->prefix(ns2),
SOAP::Data->name(“value”=> \SOAP::Data->value(
SOAP::Data->name(string=>”WK17”)->prefix(“xsd”),
),
)->prefix(ns2),

SOAP::Data->name(“dataType”=>”JOB_STREAM_NAME”)->prefix(ns2),
SOAP::Data->name(“value”=> \SOAP::Data->value(
SOAP::Data->name(string=>”IGS*”)->prefix(“xsd”),
),
)->prefix(ns2),
),
)->prefix(ns1)->type(“ns2:FilterCriteria”),

);

die $result->faultstring if ($result->fault);

#use Data::Dumper qw(Dumper);
#print Dumper ($result);

foreach my $a ($result->valueof(“//queryJobsResponse/queryJobsReturn/JobInstance”)) {
print sprintf “%-11s %-16s %-16s %-16s %-16s %-5s\n”, $a->{workstationName},
$a->{jobName},
$a->{jobStreamName},
$a->{startTime},
$a->{actualEnd},
$a->{internalStatus};
}

exit;

Leave a comment