<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/usr/bin/env perl
# the first line of the script must tell us which language interpreter to use,
# in this case its perl

# how to test this program : 
# 1. run a client that returns a ticket (eg: matrix_scan_ticket.pl)
# 2. execute this code : monitor_and_get_result_from_ticket.pl ticket

use strict;

# import the modules we need for this test; XML::Compile is included on the server
# by default.
use XML::Compile::SOAP11;
use XML::Compile::WSDL11;
use XML::Compile::Transport::SOAPHTTP;
use Data::Dumper;

eval
{
    # Retrieving and processing the WSDL
    my $wsdl  = XML::LibXML-&gt;new-&gt;parse_file('http://pedagogix-tagc.univ-mrs.fr/rsat/web_services/RSATWS.wsdl');
    my $proxy = XML::Compile::WSDL11-&gt;new($wsdl);
    
    ##### 1.  Monitor to check if the job is finished
    
    # Generating a request message based on the WSDL
    my $client = $proxy-&gt;compileClient('monitor');
    
    #Defining a few parameters
    my $ticket = $ARGV[0];

    my %args = (
	'ticket' =&gt; $ticket
	);

    # Calling the service and getting the response
    my $answer = $client-&gt;( request =&gt; {%args});

    if ( defined $answer ) {
      print "\Status of job :", $answer-&gt;{output}-&gt;{response}-&gt;{status}, "\n";
    }
    
    ##### 2. Obtain result if job is finished
	if ($answer-&gt;{output}-&gt;{response}-&gt;{status} eq "Done") {
	
	my $client = $proxy-&gt;compileClient('get_result');
	
	# Calling the service and getting the response
    my $answer = $client-&gt;( request =&gt; {%args});
	
	if ( defined $answer ) {
     	print "\nResult :\n\n", $answer-&gt;{output}-&gt;{response}-&gt;{client}, "\n";
    }
    
    }
    
};

if ($@)
{
    print "Caught an exception\n";
    print $@."\n";
    exit 1;
}</pre></body></html>