WSRF-Lite
view release on metacpan or search on metacpan
test/wsrftest.pl view on Meta::CPAN
my ( $FactoryEndPoint, $COUNTER);
if ( $COUNTERTYPE =~ m/File/ )
{
$FactoryEndPoint = $https ? "https://localhost:50000/Session/Counter/Counter" :
"http://localhost:50000/Session/Counter/Counter";
$COUNTER = "http://www.sve.man.ac.uk/Counter";
}
elsif ( $COUNTERTYPE =~ m/WSRF/ )
{
$FactoryEndPoint = $https ? "https://localhost:50000/Session/CounterFactory/CounterFactory" :
"http://localhost:50000/Session/CounterFactory/CounterFactory" ;
$COUNTER = "http://www.sve.man.ac.uk/CounterFactory";
}
elsif ( $COUNTERTYPE =~ m/MultiSession/ )
{
$FactoryEndPoint = $https ? "https://localhost:50000/MultiSession/Counter/Counter" :
"http://localhost:50000/MultiSession/Counter/Counter" ;
$COUNTER = "http://www.sve.man.ac.uk/Counter";
}
else
{
die "Do not understand Counter Type $COUNTERTYPE";
}
my $ServiceGroupTarget = $https ? "https://localhost:50000/Session/myServiceGroup/myServiceGroup" :
"http://localhost:50000/Session/myServiceGroup/myServiceGroup";
#------------------------------- UTILITIES -----------------------------------------------
my $ConvertEpochTimeToString = sub {
my ($EpochTime) = @_;
#use formatter to convert epoch time to W3CDTF TimeString
my $dt = DateTime->new( year => 1970, month => 1, day => 1 );
my $formatter = DateTime::Format::Epoch->new(epoch => $dt);
my $DateTimeObject = $formatter->parse_datetime($EpochTime);
my $f = DateTime::Format::W3CDTF->new;
my $TimeString = $f->format_datetime($DateTimeObject);
return $TimeString;
};
my $header = sub {
my ($URI,$Func,$Proxy,$resourceId) = @_;
my $ID = "<wsa:Action>".$URI."/".$Func."</wsa:Action>";
$ID .= "<wsa:To>$Proxy</wsa:To>";
$ID .= "<wsa:MessageID>uuid:".int(rand 10000000000)."</wsa:MessageID>";
if ( $resourceId ne "" )
{
$ID .= $resourceId;
}
return SOAP::Header->value($ID)->type('xml');
};
#-------------------------- END UTILITIES -----------------------------------------------
#-------------------------- METHODS -----------------------------------------------------
my $createService = sub {
my ($EndPoint,$uri) = @_;
print " Trying to create a service with namespace $uri, endpoint $EndPoint\n";
my $ans = WSRF::Lite
->uri($uri)
-> wsaddress(WSRF::WS_Address->new()->Address($EndPoint))
->createCounterResource( );
if ($ans->fault) { die "CREATE ERROR:: ".$ans->faultcode." ".$ans->faultstring."\n"; }
#Check we got a WS EndPoint back
my $address = $ans->valueof("//Body//{$WSRF::Constants::WSA}Address") or
die "CREATE ERROR:: No Endpoint returned\n";
print " Created service, Address= ($address)\n";
return ( $address);
};
my $createServiceGroup = sub {
my ($target) = @_;
my $func = "createServiceGroup";
my $ans= WSRF::Lite
-> uri($WSRF::Constants::WSSG)
-> wsaddress(WSRF::WS_Address->new()->Address($target))
-> createServiceGroup(); #function + args to invoke
if ($ans->fault) { die "CREATE ERROR:: ".$ans->faultcode." ".$ans->faultstring."\n"; }
#Check we got a WS-Address EndPoint back
my $address = $ans->valueof("//Body//{$WSRF::Constants::WSA}Address") or
die "CREATE ERROR:: No Endpoint returned\n";
print " Created service, Address= ($address)\n";
return ( $address);
};
my $addServiceToServiceGroup = sub {
my ($target) = @_;
my $StuffToAdd = '<wssg:MemberEPR xmlns:wssg="'.$WSRF::Constants::WSSG.'"
xmlns:wsa="'.$WSRF::Constants::WSA.'">
<wsa:EndpointReference>
<wsa:Address>http://localhost:50000/foobar/29710671045218021111</wsa:Address>
( run in 2.663 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )