Zend Framework

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

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.7.0, 1.7.1, 1.7.2, 1.7.3
  • Fix Version/s: 1.7.4
  • Component/s: Zend_Soap_Server
  • Labels:
    None

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).

Activity

Hide
Benjamin Eberlei added a comment -

Issue resolved, will be released in next minor release.

Show
Benjamin Eberlei added a comment - Issue resolved, will be released in next minor release.
Hide
Benjamin Eberlei added a comment -

Moved to 1.7 release branch

Show
Benjamin Eberlei added a comment - Moved to 1.7 release branch
Hide
Satoru Yoshida added a comment -

correct fix version

Show
Satoru Yoshida added a comment - correct fix version

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: