#!/bin/env perl -w
# Usage: dataverify-client.pl [--debug] [SOAP_Server_url] datasetid [...]

use SOAP::Lite; 
use XML::Simple;

my $debug = (@ARGV and $ARGV[0] eq '--debug') ? shift(@ARGV) : 0;

# this is the test SOAP server that does the verification for you
my $service = 'http://ads.harvard.edu/ws/dataverify';
# see if a different SOAP verifier has been specified as the first
# argument to the script
$service = shift(@ARGV) if (@ARGV and $ARGV[0] =~ /^http:/);
die "Usage: dataverify-client.pl [--debug] [SOAP_Server_url] datasetid [...]\n"
    unless (@ARGV);

warn "$0: connecting to SOAP proxy $cgi...\n";
SOAP::Trace->import('all') if ($debug);

$response = SOAP::Lite
    -> uri('http://ads.harvard.edu/DataVerifier')
    -> proxy($service)
    -> verify(@ARGV);

die $response->faultcode, ', ', $response->faultstring if ($response->fault);
print XMLout($response->result, noattr => 1);
