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

2512Re: [soaplite] on_fault() problems

Expand Messages
  • Duncan Cameron
    Apr 10, 2003
    • 0 Attachment
      On 2003-04-10 Chris wrote:
      > I have the following simple little program, that works fine when the
      >server is up. But if the server isn't valid, for instance if I change
      >famerptserver to famerptserver2, it will die and not call the fault
      >subroutine. I get the following output:
      >Service description
      >'http://famerptserver2:8080/ptx_webservices/services/PingFacade?wsdl'
      >can't be loaded: 500 Can't connect to famerptserver2:8080 (Bad
      >hostname 'famerptserverw2')
      >
      >
      > Why isn't the fault handler being called? Any ideas? The worst
      >part is that it basically kills the program. I could put in a die
      >handler, but I really don't like doing that.
      >
      > Chris
      >
      >By the way, it is SOAP-Lite 0.55.
      >
      >
      >
      >#!/sw/os/swhouse/perl_8.0.0/bin/perl
      >
      >use SOAP::Lite;
      >
      >use strict;
      >
      >print SOAP::Lite
      > ->
      >service('http://famerptserver:8080/ptx_webservices/services/PingFacade?wsdl')
      > -> on_fault(sub { my($soap, $res) = @_; print "I am in fault with
      >$soap and $res\n";})
      > -> ping();
      >

      The on_fault() handler is for handling those faults created by the SOAP
      server. The error of not being able to connect to the server is a
      client-side error on which SOAP::Lite just dies.

      Even if it worked in the way you want, your example wouldn't be
      correct as you don't want to continue with the ping() call. I am not even
      sure whether calling on_fault() on a service object is valid.

      Try using an eval

      eval {
      print SOAP::Lite
      ->service(<<'END')
      http://famerptserver:8080/ptx_webservices/services/PingFacade?wsdl
      END
      -> ping()
      ;
      };

      print $@ if ($@);


      Regards,
      Duncan
    • Show all 2 messages in this topic