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

trapping soap faults when using a wsdl

Expand Messages
  • James Abbott
    Hi Folks, I m having trouble trapping soap faults when access a service using SOAP::Lite accessed via a wsdl. My client code looks something like: my $wsdl =
    Message 1 of 2 , Mar 15, 2007
    View Source
    • 0 Attachment
      Hi Folks,

      I'm having trouble trapping soap faults when access a service using
      SOAP::Lite accessed via a wsdl. My client code looks something like:

      my $wsdl = 'http://address/of/service.wsdl';
      my $soap = new SOAP::Lite->service($wsdl);
      my $r =$soap->method(args);

      The service specifies it returns an array of strings in the wsdl, which
      is exactly what I get. If I use the proxy method to specify the
      endpoint, rather than the wsdl, a SOAP::SOM object is returned, with
      which I can check for the occurence of faults. The service I am using
      returns entries from a database when queried by id, so produces 'useful'
      faults like 'No entry found' for an incorrect ID which should be
      communicated to the user. So how do I go about trapping faults when I
      use the wsdl?

      An example trace output from a query generating a fault looks like this:

      SOAP::Transport::HTTP::Client::send_receive: HTTP::Response=HASH(0x8691ef8)
      SOAP::Transport::HTTP::Client::send_receive: HTTP/1.1 500 Internal
      Server Error
      Connection: close
      Date: Thu, 15 Mar 2007 18:45:37 GMT
      Server: Apache-Coyote/1.1
      Content-Type: text/xml;charset=utf-8
      Client-Date: Thu, 15 Mar 2007 18:45:37 GMT
      Client-Peer: xxx.xx.xx.xx:80
      Client-Response-Num: 1
      Client-Transfer-Encoding: chunked

      <?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>uk.ac.ebi.jdbfetch.exceptions.DbfNoEntryFoundException:
      No result found</faultstring><detail><ns1:hostname
      xmlns:ns1="http://xml.apache.org/axis/">tomcat-1.ebi.ac.uk</ns1:hostname></detail></soapenv:Fault></soapenv:Body></soapenv:Envelope>


      I checked the list archives, which suggested calling the ws method in an
      eval block and checking $@, however $@ doesn't seem to be set. I have
      also tried setting the on_fault handler, which is successfully die-ing,
      but looking at the trace output suggests this is happening on the 500
      response, prior to the soap fault being returned, since the fault this
      is missing from the resulting trace output.

      Any suggestions as to how to trap these errors?

      Thanks,
      James

      --
      Dr. James Abbott
      Bioinformatics Software Developer
      Imperial College, London
    • nicholas_toze
      The hack I ve used is to set a global $last_fault variable in the on_fault handler. Then undef it before the soap call and check if it s defined after the
      Message 2 of 2 , Jun 6, 2007
      View Source
      • 0 Attachment
        The hack I've used is to set a global $last_fault variable in the
        on_fault handler. Then undef it before the soap call and check if it's
        defined after the call.

        --- In soaplite@yahoogroups.com, James Abbott <j.abbott@...> wrote:
        >
        > Hi Folks,
        >
        > I'm having trouble trapping soap faults when access a service using
        > SOAP::Lite accessed via a wsdl. My client code looks something like:
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.