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

5914trapping soap faults when using a wsdl

Expand Messages
  • James Abbott
    Mar 15, 2007
      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
      No result found</faultstring><detail><ns1:hostname

      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?


      Dr. James Abbott
      Bioinformatics Software Developer
      Imperial College, London
    • Show all 2 messages in this topic