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

1635I can't see fault codes

Expand Messages
  • William Denton
    Jun 20, 2002
    • 0 Attachment
      Hi,

      I'm using SOAP::Lite to talk to a Windows box running .NET that gives me a
      number if I call a "createMSA" routine and give it an address. I can't
      seem to get at the fault codes with $thing->fault, however. I do this:

      use SOAP::Lite
      SOAP::Data->import('name');
      my $soap = SOAP::Lite
      -> service('http://dotnet/box/msa.asmx?WSDL') # The WSDL works fine
      -> on_fault(\&soap_error);

      my $msa = $soap -> createMSA
      (SOAP::Data ->type('string') ->name(age => '3'),
      SOAP::Data ->type('string') ->name(name => 'Throckmorton'),
      );

      print "* MSA = $msa\n"; # A number, if all went well

      unless ($msa->fault) {
      print "* msa->result = ", $msa->result(), "\n";
      } else {
      print "* Fault! ", join ', ',
      $msa->faultcode, $msa->faultstring, $msa->faultdetail;
      }

      sub soap_error {
      my ($soapObj, $res) = @_;
      if (ref $res) {
      print "(" . $res->faultcode . ") " . $res->faultstring .
      " (" . $res->faultdetail . ")\n";
      } else {
      print $soapObj->transport->status, "\n";
      }
      # exit 0; # Unused so it'll keep running
      }


      That "unless ($msa->fault)" line gives me this error when there's a fault:

      Can't call method "fault" without a package or object reference

      I coped that out of some docs, and I can't see why it doesn't work. If I
      catch faults with a subroutine, like soap_error, then I can see the
      faultcode and faultstring just fine. I'd like to see them in the main
      flow of the program, though. Am I not understanding something about the
      nature of the object? Any help most appreciated.

      Bill
      --
      William Denton : Toronto, Canada : http://www.miskatonic.org/ : Caveat lector.
    • Show all 2 messages in this topic