Perl SOAP::Lite Timeout Question

Posted on 2011-10-18
Last Modified: 2012-05-12
I have inherited a bit of code like this:

use constant API_URL => '';
use constant API_PROXY => '';

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})

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?
Question by:PaliTree
    LVL 9

    Accepted Solution

    Do the last call ($soap->on_action(...)) in an eval { }; wrapper. Then check the $@ value and handle the exception yourself.

    Author Comment

    Thanks. I'll give this a go & let you know how I get on.

    Author Closing Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Suggested Solutions

    There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
    Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now