SOAP::Lite error trapping

I

Ian Wilson

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?
 
A

A. Sinan Unur

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top