• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 810
  • Last Modified:

Perl SOAP::Lite Timeout Question

I have inherited a bit of code like this:

use constant API_URL => 'http://api.somedomain.com/api/';
use constant API_PROXY => 'http://api.somedomain.com/api/api.asmx';

my $soap = SOAP::Lite->uri(API_URL)->proxy(API_PROXY, timeout=>3 );						   
my $method = SOAP::Data->name('do_something')->attr(  { xmlns => API_URL }  );
my $response = $soap
	               ->on_action(sub { return API_URL.'do_something' })
                       ->call($method => @{$paramsArray})
        	       ->result;	

Open in new window

It works fine - mostly. But sometimes there is a network issue. When this happens the timeout value here of 3 seconds does not seem to work, as the script crashes and I get "500 Can't connect to URL :80 (connect: timeout)" in the error log.

Any ideas how I can handle a timeout problem with this?
0
PaliTree
Asked:
PaliTree
  • 2
1 Solution
 
parparovCommented:
Do the last call ($soap->on_action(...)) in an eval { }; wrapper. Then check the $@ value and handle the exception yourself.
0
 
PaliTreeAuthor Commented:
Thanks. I'll give this a go & let you know how I get on.
0
 
PaliTreeAuthor Commented:
Solved
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now