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

trouble catching fault

Expand Messages
  • Doug Fulton
    I m having difficulty catching a fault when the server returns an unexpected content type (test/html). My on_fault code never gets called. If I use die and
    Message 1 of 2 , Apr 19, 2002
    • 0 Attachment
      I'm having difficulty catching a fault when the server returns an
      unexpected content type (test/html). My on_fault code never gets
      called. If I use die and wrap $soap-> call(...) in an eval (as
      indicated in Paul's perl.com quick start article, I believe), there are
      no indications that an error occurred; if I don't use die/eval, an
      "unexpected content type" message is written to standard out (or perhaps
      standard error).

      I scanned the archives, but didn't find anyone having similar difficulty
      with what seems to be a rather trivial step. Any help is appreciated.
      Code snippet follows.

      Cheers,
      Doug

      ...

      my $soap = SOAP::Lite
      -> uri($NS)
      -> proxy($HOST)
      -> on_fault(sub {
      my($soap, $res) = @_;
      print "In on_fault sub.\n";
      ref $res ? print ERRORLOG $res -> faultstring : print
      ERRORLOG $soap->
      transport->status;
      $soapError = 1;
      }
      )
      -> deserializer(SOAP::Custom::XML::Deserializer->new)
      -> namespace($NAMESPACE);

      my $som = $soap
      ->call('h:webStatsJobs');

      if ($soapError) {
      print ERRORLOG "Exiting after soap error.\n";
      exit -1;
      }
      else {
      print "Soap success.\n";
      }
    • Dave Hoover
      ... are ... When you need to check if an error happened within an eval block, take a look at the $@ variable. See perldoc perlvar for more details. --Dave
      Message 2 of 2 , Apr 19, 2002
      • 0 Attachment
        Doug Fulton <dfulton@...> wrote:
        >If I use die and wrap $soap-> call(...) in an eval (as
        >indicated in Paul's perl.com quick start article, I believe), there
        are
        >no indications that an error occurred;

        When you need to check if an error happened within an eval block,
        take a look at the $@ variable. See 'perldoc perlvar' for more
        details.

        --Dave
      Your message has been successfully submitted and would be delivered to recipients shortly.