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

error handling

Expand Messages
  • Torsten Foertsch
    Hi, how do I catch errors in a client? I have tried this: $s=SOAP::Lite - service( http://host:8008/wsAPI?wsdl ) - on_fault(sub { my($soap, $res) = @_; use
    Message 1 of 1 , May 11 7:41 AM
    • 0 Attachment
      Hi,

      how do I catch errors in a client?

      I have tried this:

      $s=SOAP::Lite
      ->service('http://host:8008/wsAPI?wsdl')
      ->on_fault(sub {
      my($soap, $res) = @_;
      use Data::Dumper; warn Dumper($res);
      die $res->faultstring;
      });

      eval {
      $s->some_function(...);
      };

      according to the docs $res should be an object. But in my case it is a plain
      string, see below. What do I wrong?

      I'd like $res->faultstring to be "soap request contained incorrect number of
      parameters. method \'setFilter\' required 3 and request provided 4".

      Thanks,
      Torsten

      $VAR1 = 'Unspecified namespace for type \'Struct[6]\'
      <?xml version="1.0" encoding="UTF-8"?>

      <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:ns4="urn:wsAPI"
      SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
      <SOAP-ENV:Body>

      <SOAP-ENV:Fault>
      <faultcode xsi:type="xsd:QName">SOAP-ENV:Client</faultcode>
      <faultstring xsi:type="xsd:string">soap request contained incorrect number of
      parameters. method \'setFilter\' required 3 and request provided
      4</faultstring>
      <faultactor xsi:type="xsd:anyURI"></faultactor>
      <detail xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="Struct[6]"
      SOAP-ENC:offset="[0]">
      <item>
      <file
      xsi:type="xsd:string">/home/web/etracker.de/web/inc/pear/SOAP/Fault.php</file>
      <line xsi:type="xsd:int">49</line>
      <function xsi:type="xsd:string">pear_error</function>
      <class xsi:type="xsd:string">pear_error</class>
      <type xsi:type="xsd:string">::</type>
      <args xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:anyType[5]"
      SOAP-ENC:offset="[0]">
      <item xsi:type="xsd:string">soap request contained incorrect number of
      parameters. method \'setFilter\' required 3 and request provided 4</item>
      <item xsi:type="xsd:string">Client</item>
      <item/>
      <item/>
      <item xsi:type="xsd:string"></item></args></item>
      <item>
      <file
      xsi:type="xsd:string">/home/web/etracker.de/web/inc/pear/SOAP/Base.php</file>
      <line xsi:type="xsd:int">199</line>
      <function xsi:type="xsd:string">soap_fault</function>
      <class xsi:type="xsd:string">soap_fault</class>
      <type xsi:type="xsd:string">-></type>
      <args xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:anyType[6]"
      SOAP-ENC:offset="[0]">
      <item xsi:type="xsd:string">soap request contained incorrect number of
      parameters. method \'setFilter\' required 3 and request provided 4</item>
      <item xsi:type="xsd:string">Client</item>
      <item xsi:type="xsd:string"></item>
      <item xsi:type="xsd:string"></item>
      <item/>
      <item/></args></item>
      <item>
      <file
      xsi:type="xsd:string">/home/web/etracker.de/web/inc/pear/SOAP/Server.php</file>
      <line xsi:type="xsd:int">532</line>
      <function xsi:type="xsd:string">_raisesoapfault</function>
      <class xsi:type="xsd:string">soap_server</class>
      <type xsi:type="xsd:string">-></type>
      <args xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:string[4]"
      SOAP-ENC:offset="[0]">
      <item xsi:type="xsd:string">soap request contained incorrect number of
      parameters. method \'setFilter\' required 3 and request provided 4</item>
      <item xsi:type="xsd:string"></item>
      <item xsi:type="xsd:string"></item>
      <item xsi:type="xsd:string">Client</item></args></item>
      <item>
      <file
      xsi:type="xsd:string">/home/web/etracker.de/web/inc/pear/SOAP/Server.php</file>
      <line xsi:type="xsd:int">398</line>
      <function xsi:type="xsd:string">verifymethod</function>
      <class xsi:type="xsd:string">soap_server</class>
      <type xsi:type="xsd:string">-></type>
      <args xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="Struct[1]"
      SOAP-ENC:offset="[0]">
      <ns4:setFilter>
      <ns4:ticket
      xsi:type="xsd:string">d60d0fb960c5bd28c4fa54bcfc4ed05a</ns4:ticket>
      <ns4:stat_id xsi:type="xsd:string">StatisticUsagePageImpressions</ns4:stat_id>
      <ns4:filter xsi:type="xsd:string">^-[^,]+,4853,</ns4:filter>
      <ns4:c-gensym22
      xsi:type="xsd:int">4</ns4:c-gensym22></ns4:setFilter></args></item>
      <item>
      <file
      xsi:type="xsd:string">/home/web/etracker.de/web/inc/pear/SOAP/Server.php</file>
      <line xsi:type="xsd:int">170</line>
      <function xsi:type="xsd:string">parserequest</function>
      <class xsi:type="xsd:string">soap_server</class>
      <type xsi:type="xsd:string">-></type>
      <args xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:anyType[2]"
      SOAP-ENC:offset="[0]">
      <item xsi:type="xsd:string"><?xml version="1.0"
      encoding="UTF-8"?><soap:Envelope
      xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      xmlns:tns="urn:wsAPI"
      soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><tns:setFilter><ticket
      xsi:type="xsd:string">d60d0fb960c5bd28c4fa54bcfc4ed05a</ticket><stat_id
      xsi:type="xsd:string">StatisticUsagePageImpressions</stat_id><filter
      xsi:type="xsd:string">^-[^,]+,4853,</filter><c-gensym22
      xsi:type="xsd:int">4</c-gensym22></tns:setFilter></soap:Body></soap:Envelope></item>
      <item xsi:type="SOAP-ENC:Array"
      SOAP-ENC:arrayType="xsd:anyType[0]"/></args></item>
      <item>
      <file xsi:type="xsd:string">/home/web/etracker.de/web/wsAPI.php</file>
      <line xsi:type="xsd:int">61</line>
      <function xsi:type="xsd:string">service</function>
      <class xsi:type="xsd:string">soap_server</class>
      <type xsi:type="xsd:string">-></type>
      <args xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:string[1]"
      SOAP-ENC:offset="[0]">
      <item xsi:type="xsd:string"><?xml version="1.0"
      encoding="UTF-8"?><soap:Envelope
      xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema"
      xmlns:tns="urn:wsAPI"
      soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><tns:setFilter><ticket
      xsi:type="xsd:string">d60d0fb960c5bd28c4fa54bcfc4ed05a</ticket><stat_id
      xsi:type="xsd:string">StatisticUsagePageImpressions</stat_id><filter
      xsi:type="xsd:string">^-[^,]+,4853,</filter><c-gensym22
      xsi:type="xsd:int">4</c-gensym22></tns:setFilter></soap:Body></soap:Envelope></item></args></item></detail></SOAP-ENV:Fault>
      </SOAP-ENV:Body>
      </SOAP-ENV:Envelope>
      ';
    Your message has been successfully submitted and would be delivered to recipients shortly.