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

2219Re: [soaplite] proper use of on_faul()?

Expand Messages
  • Duncan Cameron
    Dec 27, 2002
      On 2002-12-26 Daryl Williams wrote:
      >folks,
      >
      >i have searched through the documentation to no avail. their error
      >handling examples use a different calling systax than the script
      >i am trying to improve, to provide better error handling.
      >
      >i've played with several different variations, but none have worked.
      >my latest try was to test the fault() value from my method's response,
      >but this does not seem to work either. actually i would rather use a
      >more glabal approach, like on_fault(), but so far i haven't found the
      >proper usage, given my script's soap calling syntax. perhaps, i am
      >doing something wrong, or there is a better way to do this. or maybe
      >the answer is right under my nose and i can't see it. any help, pointers
      >etc. are welcomed. the code looks something like this:
      >
      >use SOAP::Lite 'autodispatch';
      >sub runsoap
      >{
      > my ($vhost, $service, $method, @arglist) = @_;
      >
      > my $uri = "http://${vhost}:5253/VPSAdmin";
      > my $proxy = "http://${vhost}:5253/";
      >
      > SOAP::Lite->self->uri($uri)->proxy($proxy);
      >
      > my $soap = SOAP::Lite->self;
      > my $objname = "VPSAdmin::${service}";
      > my $obj = $objname->new($vhost);
      >
      > if ( ! defined $obj ) {
      > die_gracefully("null response from server!");
      > }
      >
      > $method_response = $obj->$method($vhost, @arglist);
      > if ( $method_response->fault ) {
      > die_gracefully($method_response->faultstring);
      > }
      >
      > return $method_response;
      >}
      >

      Because you are using autodispatch, you don't get the SOAP result
      passed back, you get the value returned by your server method.

      You need to either not use autodispatch which from your sample
      code looks the most clear approach. As the method names are passed
      as parameters there doesn't seem any benefit in using autodispatch.
      Or use the self() and call() methods to get the SOAP result and
      fault, e.g.

      my $result = SOAP::Lite->self->call->result;
      my $fault = SOAP::Lite->self->call->fault;
      # etc

      Regards,
      Duncan Cameron
    • Show all 3 messages in this topic