Re: [SOAP] PEAR::SOAP SOAP_Fault not working or not documented

From: Date: Mon, 10 Mar 2003 15:15:00 +0000
Subject: Re: [SOAP] PEAR::SOAP SOAP_Fault not working or not documented
Groups: php.soap 
Request: Send a blank email to php-soap+get-462@lists.php.net to get a copy of this message
> From shane@caraveo.com Sun Mar 9 15:14:01 2003 > > if (PEAR::isError($ret)) { > // $ret is a soap_fault object > // soap_fault subclasses the PEAR Error class. > } > > [...] > > Probably that SOAP-ENV:12345 is not a valid SOAP faultcode. Take a look > at the SOAP spec, only a few codes are valid, and they mean very > specific things. You should probably only be using either > SOAP-ENV:Client or SOAP-ENV:Server. Thanks for these clarification -- they make sense. It would be easier for PEAR::SOAP users to understand the fault handling if there they were some instances of it in the example/ directory in the distribution. Towards that end, attached are some modifications of example/server.php and example/client.php that could be incorporated into the next release. Jonathan Schilling Caldera/SCO jls@sco.com $ diff -c server.php..orig server.php *** server.php..orig Sun Sep 29 16:57:33 2002 --- server.php Mon Mar 10 09:40:04 2003 *************** *** 77,82 **** --- 77,91 ---- return new SOAP_Value('outputString','string',$inputString); } + // a method that might return a fault + function divide($dividend, $divisor) + { + if ($divisor == 0) + return new SOAP_Fault('You cannot divide by zero', 'Client'); + else + return $dividend / $divisor; + } + function echoStruct($inputStruct) { return new SOAP_Value('outputStruct','{http://soapinterop.org/xsd}SOAPStruct',$inputStruct); $ diff -c client.php..orig client.php *** client.php..orig 2003-03-10 01:23:35.000000000 -0800 --- client.php 2003-03-10 02:08:54.000000000 -0800 *************** *** 34,39 **** --- 34,51 ---- $ret = $soapclient->call("echoString",array("inputString"=>"this is a test string"),$options); print_r($ret);echo "<br>\n"; + $ret = $soapclient->call("divide",array("dividend"=>22,"divisor"=>7),$options); + if (PEAR::isError($ret)) + print("Error: " . $ret->getMessage() . "<br>\n"); + else + print("Quotient is " . $ret . "<br>\n"); + + $ret = $soapclient->call("divide",array("dividend"=>22,"divisor"=>0),$options); + if (PEAR::isError($ret)) + print("Error: " . $ret->getMessage() . "<br>\n"); + else + print("Quotient is " . $ret . "<br>\n"); + class SOAPStruct { var $varString; var $varInt;

« previous php.soap (#462) next »