1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
#!/usr/bin/env perl
use warnings;
use strict;
use XML::Compile::WSDL11;
use XML::Compile::SOAP11;
use XML::Compile::SOAP12;
use XML::Compile::Transport::SOAPHTTP;
# XML::Compile does not like dynamic things. WSDL collected with
# wget http://www.webservicex.net/ConvertTemperature.asmx?WSDL
# rename the downloaded file into convert.wsdl
my $wsdlfn = 'convert.wsdl';
my $wsdl = XML::Compile::WSDL11->new
( $wsdlfn
# , server_type => 'BEA' or 'SharePoint' or
);
my $request =
{ Temperature => 12
, FromUnit => 'degreeCelsius'
, ToUnit => 'kelvin'
};
my ($answer, $trace);
if(0)
{ ### either compile explicitly
my $convert = $wsdl->compileClient
( 'ConvertTemp'
, port => 'ConvertTemperatureSoap'
);
($answer, $trace) = $convert->($request);
}
else
{ ### or compile/use implictly
$wsdl->compileCalls(port => 'ConvertTemperatureSoap');
($answer, $trace) = $wsdl->call(ConvertTemp => $request);
}
### in either case, you can call the operations many times, with
# different $request
use Data::Dumper;
warn Dumper $answer;
# $trace->printTimings;
# $trace->printRequest(pretty_print => 1);
# $trace->printResponse(pretty_print => 1);
|