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

Issue Type: Improvement Created: 2009-08-24T04:09:11.000+0000 Last Updated: 2012-11-20T21:37:45.000+0000 Status: Open Fix version(s): Reporter: Matt Cockayne ( Assignee: None Tags: - Zend_Soap_Server

Related issues: Attachments: - Zend_Soap_Server.patch


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

<pre class="highlight">
    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);


Posted by Benjamin Eberlei (beberlei) on 2009-09-04T13:25:05.000+0000

Sounds like a maybe, i'll think about it

Posted by Amr Mostafa (alienbrain) on 2009-09-06T01:11:51.000+0000

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.

Posted by Curtis Corliss (ccorliss) on 2010-02-28T04:28:19.000+0000

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.

Posted by Curtis Corliss (ccorliss) on 2010-02-28T04:48:20.000+0000

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

Posted by Levi Stanley (niterain) on 2010-03-19T06:48:13.000+0000

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.

Have you found an issue?

See the Overview section for more details.


© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.