note 105380 added to soapclient.dorequest

From: Date: Fri, 12 Aug 2011 21:49:31 +0000
Subject: note 105380 added to soapclient.dorequest
Groups: php.notes 
Request: Send a blank email to php-notes+get-182459@lists.php.net to get a copy of this message
Note that the SoapClient.__doRequest() method circumvents the throwing of SoapFault exceptions. Specifically, if you call the __doRequest() method and it fails, it would normally throw a SoapFault exception. However, the __doRequest() method doesn't actually throw the exception. Instead, the exception is saved in a class attribute called SoapFault.__soap_fault, and is actually thrown AFTER the __doRequest method completes (but the call stack will show that the exception was created inside the __doRequest method. I successfully used the following code to query the locally cached exception object that was not thrown: $exception = null; try { $result = parent::__doRequest($request, $location, $action, $version, $one_way); } catch (SoapFault $sf) { //this code was not reached $exception = $sf; } catch (Exception $e) { //nor was this code reached either $exception = $e; } if((isset($this->__soap_fault)) && ($this->__soap_fault != null)) { //this is where the exception from __doRequest is stored $exception = $this->__soap_fault; } //decide what to do about the exception here // [enter code here] //or throw the exception if($exception != null) { throw $exception; } //note: you may want to unset the __soap_fault value if you don't want it thrown again up the call stack ---- Server IP: 69.147.83.197 Probable Submitter: 69.25.135.196 ---- Manual Page -- http://www.php.net/manual/en/soapclient.dorequest.php Edit -- https://master.php.net/note/edit/105380 Del: integrated -- https://master.php.net/note/delete/105380/integrated Del: useless -- https://master.php.net/note/delete/105380/useless Del: bad code -- https://master.php.net/note/delete/105380/bad+code Del: spam -- https://master.php.net/note/delete/105380/spam Del: non-english -- https://master.php.net/note/delete/105380/non-english Del: in docs -- https://master.php.net/note/delete/105380/in+docs Del: other reasons-- https://master.php.net/note/delete/105380 Reject -- https://master.php.net/note/reject/105380 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#182459) next »