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

4839Re: [soaplite] catching SOAP faults

Expand Messages
  • Duncan Cameron
    Aug 10, 2005
    • 0 Attachment
      On 2005-08-10 at 00:49:33 Chris wrote:

      > I have a Java axis webservice I am trying to call from perl.
      >Everything works fine as long as the proper things are passed and
      >everything is okay. However, I have a method, that takes an array of
      >elements which needs to be event. If it is not, the method returns a
      >SOAPFAULTException which should produce a soap fault. The method
      >does not return any arguments so there is not return value (it returns
      >a undef in perl just to make sure). But if I pass it an odd # of
      >aruments, the method just silently returns nothing and it goes on.
      >If I turn trace on, I can see that the method actually fails with
      >SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 500 Internal
      >Server Error
      >
      >and then I see the return fault from the service:
      ><?xml version="1.0" encoding="UTF-8"?>
      ><soapenv:Envelope
      >xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
      >xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      >xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      > <soapenv:Body>
      > <soapenv:Fault>
      > <faultcode>soapenv:Server.userException</faultcode>
      > <faultstring>javax.xml.rpc.soap.SOAPFaultException: create_event
      >failed: Arguments must be key value pairs, not an even number of
      >arguments</faultstring>
      > <detail/>
      > </soapenv:Fault>
      > </soapenv:Body>
      ></soapenv:Envelope>
      >SOAP::Transport::HTTP::Client::send_receive: POST
      >http://localhost:8080/pes_webservice/services/ProductionEventService
      >Accept: text/xml
      >Accept: multipart/*
      >Content-Length: 688
      >Content-Type: text/xml; charset=utf-8
      >SOAPAction: ""
      >
      >In addition, if the webserver return any fault to any method, it is
      >quietly ignored. How can I get back the faults in perl SOAP::Lite?
      >Since the return value is undef, I cannot look at $ret->fault, or
      >anyting like that?

      That us exactly what you do look at.

      my $som = $soap->some_method();

      if ($som->fault) {
      print $som->faultcode;
      } else {
      # it worked
      print $som->result;
      }

      Regards

      Duncan Cameron
    • Show all 3 messages in this topic