ZF-7670: Handling "Unknown Error" from unregistered soap exceptions


When using the soap server in a large multifunctional application and an Exception occurs that is not found in registered Exception types It throw a rather unhelpful "Unknown Error".

I have had to edit the Fault method in Zend_Soap_Server. to allow the passing of non registered exceptions.

My patch is quick and dirty but it may be worth adding an option flag that can be set to allow the use of unregistered Exceptions.

method now reads as

    public function fault($fault = null, $code = "Receiver")
        if ($fault instanceof Exception) {
            $class = get_class($fault);
            if (in_array($class, $this->_faultExceptions)) {
                $message = $fault->getMessage();
                $eCode   = $fault->getCode();
                $code    = empty($eCode) ? $code : $eCode;
            } else {
                $eCode   = $fault->getCode();
                $code    = empty($eCode) ? $code : $eCode;
                $message = 'Unregistered Exception: "'.$class.'" '.$fault->getMessage();
        } elseif(is_string($fault)) {
            $message = $fault;
        } else {
            $message = 'Unknown error';

        $allowedFaultModes = array(
            'VersionMismatch', 'MustUnderstand', 'DataEncodingUnknown',
            'Sender', 'Receiver', 'Server'
        if(!in_array($code, $allowedFaultModes)) {
            $code = "Receiver";

        return new SoapFault($code, $message);


Sounds like a maybe, i'll think about it

Perhaps one simple way of doing that is to check using {{instanceof}} instead of {{get_class}}. That way, if someone wants to allow all exceptions, they can register the base exception class {{Exception}}.

I agree with the concept of registering exceptions with the soap server, as opposed to directly returning all exceptions as seen in the description code. However - I don't think comparing the class name as a string is the best approach. This can make error handling very cumbersome in more complex applications.

I have attached a patch to check if the thrown exception is an instance of a registered exception.

Can you review this patch? I don't have commit privileges yet.

Interesting, I was getting this error last month, ended up just using Zend's autodiscovery, and using php's soap server directly instead. Since it gave more useful information.