Issues

ZF-5586: Extend Zend_Soap_Server and overwrite method "_initializeSoapErrorContext" and error_handler with E_ALL -> "loadXML()" error

Description

A small excerpt from my code (overwrite standard error_handler from Zend_Soap_Server:


<?php
class Ms_Soap_Server extends Zend_Soap_Server
{
    protected function _initializeSoapErrorContext()
    {
        $displayErrorsOriginalState = ini_get('display_errors');
        ini_set('display_errors', false);
        
        //  Standard = E_USER_ERROR
        set_error_handler(array($this, 'handlePhpErrors'), E_ALL);
        return $displayErrorsOriginalState;
    }
    
    public function handlePhpErrors($errno, $errstr, $errfile = null, $errline = null, array $errcontext = null) 
    {       
        switch ($errno)
        {
            case E_USER_ERROR:
                $soapErrorCode = 'Receiver';
            break;
            
            default:
                $errstr = 'Sorry, internal server error!';
                $soapErrorCode = 'Server';
            break;
        }
        
        throw $this->fault($errstr, $soapErrorCode);
    }
}
?>

When I make an "empty request" to the SoapServer via a web browser (http://www.xxx.com/server/) the answer must be an XML document with an SoapFault "Invalid XML". But that is not possible because of the code beginning on line 612 (SVN)

if (!$dom->loadXML($xml)) {
    require_once 'Zend/Soap/Server/Exception.php';
    throw new Zend_Soap_Server_Exception('Invalid XML');
}

See DOMDocument::loadXML: "Errors/Exceptions: If an empty string is passed as the source, a warning will be generated."

Before the "loadXML" is called, it should be checked for an empty XML-Document (request) as follows:


if ($xml == '' || !$dom->loadXML($xml)) {
    require_once 'Zend/Soap/Server/Exception.php';
    throw new Zend_Soap_Server_Exception('Invalid XML');
}

So it works smoothly when I overwrite the error handler of the Zend_Soap_Server class to return individual error messages for example when a database connetection is impossible -> SoapFault: Sorry, internal server error.

In addition, the word "Reciever" in the class Zend_Soap_Server" should be replaced with "Receiver" (at line 832, 851, 873).

Comments

Issue resolved, will be released in next minor release.

Moved to 1.7 release branch

correct fix version