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