Subject: | Client unable to detect fatal SOAP failure (e.g. unable to connect to host) |
With a base install of SOAP::Lite version 0.66 I don't think it is
possible for the user/developer to detect whether the SOAP 'call'
failed, and I consider this a bug.
For example, the following code returns the empty string ('') if
SOAP::Lite is unable to communicate with the SOAP server:
$soap->call(SOAP::Data->name($action) => $soapdata)
This does not allow the user/developer to easily determine that there
has been a fatal error.
Within SOAP::Transport::HTTP the response structure is as follows during
this instance:
$VAR1 = bless( {
'_content' => '',
'_rc' => 500,
'_headers' => bless( {
'client-date' => 'Wed, 25 Jan
2006 15:56:32 GMT'
}, 'HTTP::Headers' ),
'_msg' => 'Can\'t connect to a.b.c:80 (connect:
Connection refused)',
'_request' => ...
_content is what is being returned to the client, where what would
actually be more useful would be to push _msg up to the client through
SOAP::Lite.
I have rolled a small patch (attached) which will at least allow the
user/developer to detect the 'undef' and handle that error case, but it
doesn't expose the actual cause of the error "Can't connect to a.b.c",
so I don't think this is the _correct_ fix. I hope it demonstrates the
bug, though.
Ollie
Subject: | HTTP.pm.patch |
--- /root/.cpan/build/SOAP-Lite-0.66/lib/SOAP/Transport/HTTP.pm 2005-10-19 00:43:23.000000000 +0000
+++ /usr/lib/perl5/site_perl/5.8.0/SOAP/Transport/HTTP.pm 2006-01-25 15:29:39.000000000 +0000
@@ -222,6 +222,10 @@
$self->is_success($self->http_response->is_success);
$self->status($self->http_response->status_line);
+ # If the HTTP request did not succeed (e.g. unable to connect to the host)
+ # allow the client to trap and handle the error by returning undef.
+ return(undef) if ($self->http_response->is_success == 0);
+
my $content =
($self->http_response->content_encoding || '')
=~ /\b$SOAP::Transport::HTTP::Client::COMPRESS\b/o &&