Loading ...
Sorry, an error occurred while loading the content.

25on_fault

Expand Messages
  • Ray Rizzuto
    Feb 13, 2001
      Hi!

      I'd like to be able to handle all errors from a soap call, including
      transport errors, after the call completes. I've set the following
      fault handler, which almost works except that the faultstring isn't
      available after the call to the method:

      sub fault
      {
      my($soap, $res) = @_;
      if (defined $res && ref $res)
      {
      print $res->faultstring;
      return $res;
      }
      else
      {
      print $soap->transport->status;
      $res = new SOAP::SOM;
      $res->faultstring("transport error");
      return $res;
      }
      }


      Here's the call and the test of faultstring:

      my $soap = SOAP::Lite->new(
      uri =>'http://pc-rizzuto-p/Demo',
      proxy =>'http://pc-rizzuto-p:9999/',
      on_fault => \&fault);

      my $result = $soap->call('hi');

      if (!$result->faultstring)
      {
      print $result->result;
      }
      else
      {
      print $soap->faultstring;
      }

      I'm very new to this, so I may be making an obvious mistake.

      Ray
    • Show all 9 messages in this topic