I am making a soap call from inside a try...catch block,
$request->l_Request->Year = $year;
// $request->l_Request->Period = $period;
try {
/**
*
* perform getMake request
* @var stdClass
*/
$response = $client->getSeries($request);
$series = $response->getSeriesResult->Lookup_Struc;
return $series;
} catch (SoapFault $exception) {
/**
* log exception on soap request
*/
$this->getLogger()->log($exception->getMessage(), Zend_Log::ERR);
$this->getLogger()->log($exception->getTraceAsString(), Zend_Log::INFO);
return false;
} catch (Exception $exception) {
/**
* log exception on soap request
*/
$this->getLogger()->log($exception->getMessage(), Zend_Log::ERR);
$this->getLogger()->log($exception->getTraceAsString(), Zend_Log::INFO);
return false;
}
Here's how my output/error looks like
( ! ) Fatal error: SOAP-ERROR: Encoding: object has no 'Period' property in C:\wamp\www\FHH\library\Zend\Soap\Client.php on line 1121
But I am unable to catch soap-error using try catch, Is there special way to handle this.
I use the following class in my applications to turn errors into exceptions:
class ErrorHandler
{
public function __construct()
{
set_error_handler( array( __CLASS__, 'handleError' ));
}
static public function handleError( $errno, $errstr, $errfile,
$errline, array $errcontext )
{
throw new ErrorException( $errstr, 0, $errno, $errfile, $errline );
}
}
You just need to create an instance of it:
$errorHandler = new ErrorHandler();
An alternative if you're using ZF1 MVC is to rename the constructor to __initErrorHandler()
and add those two methods to your bootstrap class.
I have successfully used this approach in code that uses Zend_Soap_Server
, so hopefully it will work for you too.