Subject: | clashing sub names with Try::Tiny module |
Hi there,
I was doing some tests with XML-Compile-WSDL11 and all was fine until I decided to turn on the trace mode with:
use Log::Report mode => 'DEBUG';
On the script I created for testing, which has a part that uses Try::Tiny module to catch errors and do something about this.
The script:
my $wsdl = XML::Compile::WSDL11->new($wsdlfile);
my $auth = Siebel::SOAP::Auth->new( { user => 'user', password => 'password' } );
my $call = $wsdl->compileClient( operation => 'SWIContactServicesQueryByExample', transport_hook => sub { $auth->add_auth_header(@_) } );
my $response_ok = 1;
print 'Starting test at ', scalar(localtime(time())), "\n";
my ($answer, $trace) = $call->(%request);
$auth->find_token( $answer );
print Dumper($answer);
while ( $response_ok ) {
try {
sleep( int(rand(11)) + 10 );
my ($answer, $trace) = $call->(%request);
$auth->find_token( $answer );
} catch {
warn $_;
if ( $_ eq 'token expired' ) {
print 'token expired, ending test at ', scalar(localtime(time())), "\n";
$response_ok = 0;
} else {
die $_;
}
};
}
No error is generated until I "use Log::Report mode => 'DEBUG';". In this case, this is the error generated (I omitted must of the output to make it short):
trace: received 200 OK
trace: using preparsed XML document with element <{http://schemas.xmlsoap.org/soap/envelope/}Envelope>
trace: node {http://siebel.com/webservices}SessionToken not understood, expected are (none)
trace: using preparsed XML node <{http://siebel.com/asi/V0}SWIContactServicesQueryByExample_Output>
panic: odd length parameter list for try(): forgot the terminating ';'?
at siebel_ws2.pl line 53
Log::Report::try("CODE(0x46893d0)", "Try::Tiny::Catch=REF(0x4419978)") at siebel_ws2.pl line 53
This error is avoidable if I use the full name for "try" and "catch" functions of Try::Tiny module:
Try::Tiny::try {
sleep( int(rand(11)) + 10 );
my ($answer, $trace) = $call->(%request);
$auth->find_token( $answer );
} Try::Tiny::catch {
warn $_;
if ( $_ eq 'token expired' ) {
print 'token expired, ending test at ', scalar(localtime(time())), "\n";
$response_ok = 0;
} else {
die $_;
}
};
Ugly, but works as expected, both with the trace turned on/off. I probably will be releasing Siebel::SOAP::Auth to CPAN as is (depending on XML::Compile::WSDL, Log::Report), but I'm not sure if it a good idea. The module Siebel::SOAP::Auth will provide transparent authentication for Siebel applications by using Session Management, but I was thinking on rely on Try::Tiny to catch exceptions.
Regards,
Alceu