on_fault()
This lets you specify a handler for "on_fault" event. The
default behavior is to die on an transport error and to do
nothing on other error conditions. You may change this
behavior globally (see "DEFAULT SETTINGS") or locally,
for a particular object.
Something like this has worked for me quite well:
# Something to store all the soap errors in - this is useful # if your code calls the soap service in a loop. # our @SOAP_ERRORS = (); .... # Get the current number of soap errors # my $error_count = scalar( @SOAP_ERRORS ); my $service = SOAP::Lite -> on_fault( \&soapGetBad ) -> service('http://server/function.asmx?WSDL'); # If the previous number of errors is the same as the current # number of errors, you know that the above service call did # not cause an error so you can process the results or whatever. # if( scalar( @SOAP_ERRORS ) == $error_count ) { ... } .... sub soapGetBad { my $soap = shift; my $res = shift; if( ref( $res ) ) { chomp( my $err = $res->faultstring ); push( @SOAP_ERRORS, "SOAP FAULT: $err" ); } else { chomp( my $err = $soap->transport->status ); push( @SOAP_ERRORS, "TRANSPORT ERROR: $err" ); } return new SOAP::SOM; }
In reply to Re: Soap::Lite Error Handling
by ghoti
in thread Soap::Lite Error Handling
by ecuguru
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |