SOAP::Lite error trapping

Discussion in 'Perl Misc' started by Ian Wilson, Jun 1, 2004.

  1. Ian Wilson

    Ian Wilson Guest

    My perl SOAP client dies if the SOAP server isn't there, but I wish to
    handle this error without the script dying.

    My code is ...
    $webservice = 'http://foo:80/cgi-bin/soapservice.pl';
    $uri = 'exampleAPI';

    ...

    my $client=SOAP::Lite
    ->uri($uri)
    ->readable(1)
    ->proxy($webservice);

    ...

    my $response=$client->SendDocument(myXMLobj);

    unless ($response->fault) {
    logexit ($filename, $response->result(), "Sent OK");
    } else {
    logexit ($filename, $response->faultcode, $response->faultstring);
    }

    This normally works and I can log faultcodes returned by the server.

    To test what happens if the server is not available I put a bad hostname
    in $webservice. I then get the script falling over with
    500 Can't connect to bar:80 (Bad hostname 'bar') \
    at ./test.pl line 186

    I'm a little surpised this situation doesn't simply return a
    $response->fault, what is the idiom for handling this type of error?
     
    Ian Wilson, Jun 1, 2004
    #1
    1. Advertising

  2. Ian Wilson <> wrote in news:c9i406$fl9$1
    @hercules.btinternet.com:

    > To test what happens if the server is not available I put a bad hostname
    > in $webservice. I then get the script falling over with
    > 500 Can't connect to bar:80 (Bad hostname 'bar') \
    > at ./test.pl line 186
    >
    > I'm a little surpised this situation doesn't simply return a
    > $response->fault, what is the idiom for handling this type of error?
    >


    perldoc -f eval

    --
    A. Sinan Unur
    (reverse each component for email address)
     
    A. Sinan Unur, Jun 1, 2004
    #2
    1. Advertising

  3. Ian Wilson

    Ian Wilson Guest

    Ian Wilson wrote:

    > My perl SOAP client dies if the SOAP server isn't there, but I wish to
    > handle this error without the script dying.


    Somehow I missed ...
    http://guide.soaplite.com/#error handling examples 2g etc

    Apologies for wasting some bandwidth.
     
    Ian Wilson, Jun 1, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rushikesh Joshi
    Replies:
    0
    Views:
    438
    Rushikesh Joshi
    Aug 19, 2004
  2. Aaron Brady

    SQL, lite lite lite

    Aaron Brady, Dec 29, 2008, in forum: Python
    Replies:
    15
    Views:
    761
    Aaron Brady
    Jan 1, 2009
  3. doug
    Replies:
    2
    Views:
    261
  4. Rushikesh Joshi
    Replies:
    0
    Views:
    92
    Rushikesh Joshi
    Aug 19, 2004
  5. droesler
    Replies:
    2
    Views:
    511
    droesler
    Aug 31, 2010
Loading...

Share This Page