WSRF-Lite
view release on metacpan or search on metacpan
$ans= WSRF::Lite
-> uri($uri) #set the namespace
-> wsaddress(WSRF::WS_Address->new()->Address($target)) #location of service
-> $func(@ARGV); #function + args to invoke
Note the use of WSRF::Lite instead of SOAP::Lite. Instead of using
->proxy($target) we now use ->wsaddress passing it a WS_Address
object created using the endpoint of the service. This client will
automatically create the correct WS-Addressing SOAP Headers, there
is no longer any need to create a SOAP::Header object with the
WS-Addressing information.
The WS_Address funtion 'from_envelope' takes either an WS-Addressing
EPR encoded as XML or as a SOM object and returns a WS_Address object:
eg.
$som = WSRF::Lite
->uri("http://localhost:50000/CounterFactory")
->wsaddress(WSRF::WS_Address->new()
Server Side
===========
sub serviceOperation {
my $envelope = pop @_;
$SigningPolicy = WSS::SigningPolicy->new();
$SigningPolicy->sign('Body' => namespace);
die "Not signed\n" unless
WSS::verify($envelope,$SigningPolicy);
$header = SOAP::Header->new()....
$data = SOAP::data->new()....
#sign the response using the rules defined by $SigningPolicy
return $header, $data, $SigningPolicy;
}
Client Side
===========
lib/WSRF/Lite.pm view on Meta::CPAN
'xmlns:wsu' => $WSRF::Constants::WSU,
'xmlns:wsse' => $WSRF::Constants::WSSE
}
);
my $type = shift;
my ( @parameters, @header );
for (@_) {
# Find all the SOAP Headers
if ( defined($_) && ref($_) && UNIVERSAL::isa( $_ => 'SOAP::Header' ) )
{
push( @header, $_ );
# Find all the SOAP Message Parts (attachments)
} elsif ( defined($_)
&& ref($_)
&& $self->context
&& $self->context->packager->is_supported_part($_) )
{
$self->context->packager->push_part($_);
lib/WSRF/Lite.pm view on Meta::CPAN
'xmlns:wsu' => $WSRF::Constants::WSU,
'xmlns:ds' => $WSRF::Constants::DS,
'xmlns:wsse' => $WSRF::Constants::WSSE
}
);
my ( @parameters, @header );
for (@_) {
# Find all the SOAP Headers
if ( defined($_) && ref($_) && UNIVERSAL::isa( $_ => 'SOAP::Header' ) )
{
push( @header, $_ );
# Find all the SOAP Message Parts (attachments)
} elsif ( defined($_)
&& ref($_)
&& $self->context
&& $self->context->packager->is_supported_part($_) )
{
$self->context->packager->push_part($_);
lib/WSRF/Lite.pm view on Meta::CPAN
}
my ($PUT);
if ( $request->method eq 'PUT' ) {
$PUT = 1;
my $To = $ENV{URL};
chop $To;
$To .= $request->uri;
my $header =
SOAP::Header->value( "<wsa:To>" . $To . "</wsa:To>" )->type('xml');
my $xml = $request->content;
print STDERR "$$ Attempt to PUT\n";
$xml =~ s/^<\?xml[\s\w\.\-].*\?>\n?//o;
print STDERR "$$ >>>xml>>>\n$xml\n<<<xml<<<\n";
my $data =
SOAP::Data->name('PutResourcePropertyDocument')->prefix('wsrp')
->attr( { 'xmlns:wsrp' => $WSRF::Constants::WSRP } )
lib/WSRF/Lite.pm view on Meta::CPAN
#wants ResourceProperties
$GET = 1;
my $data =
SOAP::Data->name('GetResourcePropertyDocument')->prefix('wsrp')
->attr( { 'xmlns:wsrp' => $WSRF::Constants::WSRP } );
my $To = $ENV{URL};
chop $To;
$To .= $request->uri;
my $header =
SOAP::Header->value( "<wsa:To>" . $To . "</wsa:To>" )->type('xml');
my $envelope = WSRF::WSRFSerializer->new()->freeform( $header, $data );
$request = HTTP::Request->new();
$request->method('POST');
$request->header( "SOAPAction" =>
"$WSRF::Constants::WSRP/GetResourcePropertyDocument" );
$request->header( "Content-Length" => length $envelope );
$request->content($envelope);
}
if ( $request->method eq 'DELETE' ) {
my $data =
SOAP::Data->name('Destroy')->prefix('wsrl')
->attr( { 'xmlns:wsrl' => $WSRF::Constants::WSRL } );
my $To = $ENV{URL};
chop $To;
$To .= $request->uri;
my $header =
SOAP::Header->value( "<wsa:To>" . $To . "</wsa:To>" )->type('xml');
my $envelope = WSRF::WSRFSerializer->new()->freeform( $header, $data );
$request = HTTP::Request->new();
$request->method('POST');
$request->header( "SOAPAction" => "$WSRF::Constants::WSRL/Destroy" );
$request->header( "Content-Length" => length $envelope );
$request->content($envelope);
}
my $rend = $WSRF::Constants::SOCKETS_DIRECTORY . "/" . $ID;
lib/WSRF/Lite.pm view on Meta::CPAN
}
my ($PUT);
if ( $request->method eq 'PUT' ) {
$PUT = 1;
my $To = $ENV{URL};
chop $To;
$To .= $request->uri;
my $header =
SOAP::Header->value( "<wsa:To>" . $To . "</wsa:To>" )->type('xml');
my $xml = $request->content;
print STDERR "$$ Attempt to PUT\n";
$xml =~ s/^<\?xml[\s\w\.\-].*\?>\n?//o;
print STDERR "$$ >>>xml>>>\n$xml\n<<<xml<<<\n";
my $data =
SOAP::Data->name('PutResourcePropertyDocument')->prefix('wsrp')
->attr( { 'xmlns:wsrp' => $WSRF::Constants::WSRP } )
lib/WSRF/Lite.pm view on Meta::CPAN
}
$GET = 1;
my $data =
SOAP::Data->name('GetResourcePropertyDocument')->prefix('wsrp')
->attr( { 'xmlns:wsrp' => $WSRF::Constants::WSRP } );
my $To = $ENV{URL};
chop $To;
$To .= $request->uri;
my $header =
SOAP::Header->value( "<wsa:To>" . $To . "</wsa:To>" )->type('xml');
my $envelope = WSRF::WSRFSerializer->new()->freeform( $header, $data );
$request = HTTP::Request->new();
$request->method('POST');
$request->header( "SOAPAction" =>
"$WSRF::Constants::WSRP/GetResourcePropertyDocument" );
$request->header( "Content-Length" => length $envelope );
$request->content($envelope);
}
if ( $request->method eq 'DELETE' ) {
my $data =
SOAP::Data->name('Destroy')->prefix('wsrl')
->attr( { 'xmlns:wsrl' => $WSRF::Constants::WSRL } );
my $To = $ENV{URL};
chop $To;
$To .= $request->uri;
my $header =
SOAP::Header->value( "<wsa:To>" . $To . "</wsa:To>" )->type('xml');
my $envelope = WSRF::WSRFSerializer->new()->freeform( $header, $data );
$request = HTTP::Request->new();
$request->method('POST');
$request->header( "SOAPAction" => "$WSRF::Constants::WSRL/Destroy" );
$request->header( "Content-Length" => length $envelope );
$request->content($envelope);
}
print STDERR "$$ Dispatch path $Directory\n";
my %namespacemap = (
lib/WSRF/Lite.pm view on Meta::CPAN
}
my ($PUT);
if ( $request->method eq 'PUT' ) {
$PUT = 1;
my $To = $ENV{URL};
chop $To;
$To .= $request->uri;
my $header =
SOAP::Header->value( "<wsa:To>" . $To . "</wsa:To>" )->type('xml');
my $xml = $request->content;
print STDERR "$$ Attempt to PUT\n";
$xml =~ s/^<\?xml[\s\w\.\-].*\?>\n?//o;
print STDERR "$$ >>>xml>>>\n$xml\n<<<xml<<<\n";
my $data =
SOAP::Data->name('PutResourcePropertyDocument')->prefix('wsrp')
->attr( { 'xmlns:wsrp' => $WSRF::Constants::WSRP } )
lib/WSRF/Lite.pm view on Meta::CPAN
}
$GET = 1;
my $data =
SOAP::Data->name('GetResourcePropertyDocument')->prefix('wsrp')
->attr( { 'xmlns:wsrp' => $WSRF::Constants::WSRP } );
my $To = $ENV{URL};
chop $To;
$To .= $request->uri;
my $header =
SOAP::Header->value( "<wsa:To>" . $To . "</wsa:To>" )->type('xml');
my $envelope = WSRF::WSRFSerializer->new()->freeform( $header, $data );
$request = HTTP::Request->new();
$request->method('POST');
$request->header( "SOAPAction" =>
"$WSRF::Constants::WSRP/GetResourcePropertyDocument" );
$request->header( "Content-Length" => length $envelope );
$request->content($envelope);
}
if ( $request->method eq 'DELETE' ) {
my $data =
SOAP::Data->name('Destroy')->prefix('wsrl')
->attr( { 'xmlns:wsrl' => $WSRF::Constants::WSRL } );
my $To = $ENV{URL};
chop $To;
$To .= $request->uri;
my $header =
SOAP::Header->value( "<wsa:To>" . $To . "</wsa:To>" )->type('xml');
my $envelope = WSRF::WSRFSerializer->new()->freeform( $header, $data );
$request = HTTP::Request->new();
$request->method('POST');
$request->header( "SOAPAction" => "$WSRF::Constants::WSRL/Destroy" );
$request->header( "Content-Length" => length $envelope );
$request->content($envelope);
}
#check if a process to handle this message has been created
my $SockPath = $WSRF::Constants::SOCKETS_DIRECTORY . '/' . $module;
lib/WSRF/Lite.pm view on Meta::CPAN
return;
}
sub unlock {
my ($self) = @_;
my $Lock = $self->{_lock};
$Lock->DESTROY();
}
#===============================================================================
# header function creates a SOAP::Header that should be included
# in the response to the client. Handles the WS-Address stuff.
# Takes the original envelope and creates a Header from it -
# the second paramter will be stuffed into the Header so must
# be XML
#
# BUG This should be better automated - probably in the SOAP serializer,
# not sure how because we need to remember the MessageID
package WSRF::Header;
=pod
lib/WSRF/Lite.pm view on Meta::CPAN
$envelope->headerof("//{$WSRF::Constants::WSA}MessageID")->value;
$myHeader .=
"<wsa:RelatesTo wsu:Id=\"RelatesTo\">"
. $messageID
. "</wsa:RelatesTo>";
}
#append anything else the user has given us
$myHeader .= $anythingelse;
#create the SOAP::Header object and return to client
return SOAP::Header->value($myHeader)->type('xml');
}
#===============================================================================
# Base class for the process based WSRF services - a Service can inherit from
# this class to pick up GetResourceProperty, GetMultiResourceProperties and
# SetResourceProperty operations.
package WSRF::WSRP;
=pod
lib/WSRF/Lite.pm view on Meta::CPAN
. $self->wsaddress->MessageID()
. "</wsa:MessageID>";
$header .=
$self->wsaddress->serializeReferenceParameters()
? $self->wsaddress->serializeReferenceParameters()
: '';
#bug fix - John Newman
$header .=
"<wsa:ReplyTo wsu:Id=\"ReplyTo\"><wsa:Address>$WSRF::Constants::WSA_ANON</wsa:Address></wsa:ReplyTo>";
@_ = ( @_, SOAP::Header->value($header)->type('xml') );
}
my $response = $self->transport->send_receive(
context => $self, # this is provided for context
endpoint => $self->endpoint,
action =>
scalar( $self->on_action->( $serializer->uriformethod( $_[0] ) ) ),
# leave only parameters so we can later update them if required
envelope => $serializer->envelope( method => shift, @_ ),
test/wsrftest.pl view on Meta::CPAN
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) = @_;
( run in 0.258 second using v1.01-cache-2.11-cpan-454fe037f31 )