ZF-12100: Stack overflow in Zend_Soap_AutoDiscover
Description
When the Zend_Soap_AutoDiscover uses the strategy Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence, bidirectional associations between classes cause infinite recursion.
Consider the following example:
class AuthorTO {
/**
* @var integer
*/
public $id;
/**
* @var string
*/
public $name;
/**
* @var AuthorsListItemTO[]
*/
public $authorsListItemList;
}
class AuthorsListItemTO {
/**
* @var integer
*/
public $id;
/**
* @var AuthorTO
*/
public $author;
/**
* @var string
*/
public $book;
}
class BooksManagementFacadeBean {
/**
*
* @param integer $id
* @return AuthorTO
*/
public function getAuthorByID($id) {
$service = new BooksService();
$result = $service->getAuthorByID($id);
return $result;
}
}
$autodiscover = new Zend_Soap_AutoDiscover('Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence');
$autodiscover->setBindingStyle(array('style' => 'document'));
$autodiscover->setOperationBodyStyle(
array('use' => 'literal',
'namespace' => 'http://framework.zend.com')
);
$autodiscover->setClass('BooksManagementFacadeBean');
$autodiscover->handle();
The problem is caused by the association "Author has many AuthorsListItem", "AuthorsListItem has an Author". Changing "@var AuthorTO" to "@var string" in the class AuthorsListItemTO solves the problem.
Comments
Posted by Frank Brückner (frosch) on 2012-03-15T11:19:52.000+0000
Code tags added.