ConFoo Montreal 2026: Call for Papers

Voting

: eight plus one?
(Example: nine)

The Note You're Voting On

bwhitehead at tableausoftware dot no dot com dot spam
13 years ago
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:

<?php
$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
?>

<< Back to user notes page

To Top