Skip Menu |

This queue is for tickets about the XML-Compile-WSDL11 CPAN distribution.

Report information
The Basics
Id: 108200
Status: resolved
Priority: 0/
Queue: XML-Compile-WSDL11

People
Owner: Nobody in particular
Requestors: arfreitas [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 3.04
Fixed in: (no value)



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
Subject: Re: [rt.cpan.org #108200] clashing sub names with Try::Tiny module
Date: Fri, 30 Oct 2015 16:21:47 +0100
To: Alceu Rodrigues de Freitas Junior via RT <bug-XML-Compile-WSDL11 [...] rt.cpan.org>
From: Mark Overmeer <solutions [...] overmeer.net>
* Alceu Rodrigues de Freitas Junior via RT (bug-XML-Compile-WSDL11@rt.cpan.org) [151030 14:50]: Show quoted text
> Fri Oct 30 10:49:53 2015: Request 108200 was acted upon. > Transaction: Ticket created by ARFREITAS > Queue: XML-Compile-WSDL11 > Subject: clashing sub names with Try::Tiny module > Broken in: 3.04 > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=108200 > > > 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';
You did not invoke Log::Report in the older version? Log::Report imports a range of commands, like 'info', 'notice', 'panic', 'dispatcher', and 'try'. You can avoid that with use Log::Report mode => 'DEBUG', import => []; Show quoted text
> 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 $_; > } > };
With Log::Report's try() you would write try { sleep rand(11) + 10; my ($answer, $trace) = $call->(%request); $auth->find_token( $answer ); }; if(my $e = $@->wasFatal) { if($e =~ /token expired/) ... else { $e->throw } } Show quoted text
> 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)
This means that your SessionToken gets ignored. Unless a field in the header contains mustUnderstand="true", they are simply ignored. Show quoted text
> 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
Yes, that's "my" version of try() which has a different prototype. Show quoted text
> 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.
So, the trace shows that the SessionToken does not get processed at all. Probably you need something like XML::Compile::SOAP::WSA -- Regards, MarkOv ------------------------------------------------------------------------ Mark Overmeer MSc MARKOV Solutions Mark@Overmeer.net solutions@overmeer.net http://Mark.Overmeer.net http://solutions.overmeer.net
Em Sex Out 30 11:22:10 2015, solutions@overmeer.net escreveu: Show quoted text
> You did not invoke Log::Report in the older version? Log::Report > imports > a range of commands, like 'info', 'notice', 'panic', 'dispatcher', and > 'try'. You can avoid that with > use Log::Report mode => 'DEBUG', import => [];
I used the newest version available of Log::Report. Show quoted text
> With Log::Report's try() you would write > > try { sleep rand(11) + 10; > my ($answer, $trace) = $call->(%request); > $auth->find_token( $answer ); > }; > if(my $e = $@->wasFatal) > { if($e =~ /token expired/) ... > else { $e->throw } > }
Thanks! I just did that and it worked. I didn't realized initially that XML::Compile::WSDL11 had it's own mechanism to deal with exceptions. Now that I actually read the documentation it is now clearer. Show quoted text
> > 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)
> > This means that your SessionToken gets ignored. Unless a field in the > header contains mustUnderstand="true", they are simply ignored.
Understood, but for my purposes leaving it as is it's the expected thing. Siebel just created their own implementation for authentication. Show quoted text
> So, the trace shows that the SessionToken does not get processed at > all. Probably you need something like XML::Compile::SOAP::WSA
After applying the changes you suggested, it all worked as expected. It could be avoided if I have read all the documentation available, which in fact could be improved. If you are willing to accept patches on Pod for that, please let me know. On the other hand, by following the documentation to use transport_hook also for mocking results, I think I got another issue: when creating manually the XML response expected, I made a mistake and introduced a syntax error on the XML. The thing is the script stopped working without any error message. I was able to caught that there were an exception because I used the debugger. After it, I just checked $@ for exceptions and caught the same error. Before doing that, the program stopped working silently, which is never a good thing. I can try again to reproduce the same error and send you a test file. Anyway, for this case I think you can closed since there is no bug. Thank you for your help! Siebel::SOAP::Auth should be release in the next few days to CPAN thanks to your inputs.