ZF-4937: Autodiscover doesn't work with complex types and arrays.
Description
I tried to make a wsdl file with the svn-trunk version of the Zend framework, I get the following error:
Fatal error: Uncaught exception 'Zend_Soap_Wsdl_Exception' with message 'Trying to add a type 'test that is already part of the WSDL.' in /zend-test/Zend/Soap/Wsdl.php:443
Stack trace:
0 /zend-test/Zend/Soap/Wsdl/Strategy/DefaultComplexType.php(65): Zend_Soap_Wsdl->addType('test')
1 /zend-test/Zend/Soap/Wsdl/Strategy/ArrayOfTypeComplex.php(98): Zend_Soap_Wsdl_Strategy_DefaultComplexType->addComplexType('test')
2 /zend-test/Zend/Soap/Wsdl/Strategy/ArrayOfTypeComplex.php(59): Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex->_addObjectComplexType('test')
3 /zend-test/Zend/Soap/Wsdl.php(581): Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex->addComplexType('test')
4 /zend-test/Zend/Soap/Wsdl.php(544): Zend_Soap_Wsdl->addComplexType('test')
5 /zend-test/Zend/Soap/AutoDiscover.php(243): Zend_Soap_Wsdl->getType('test')
6 /zend-test/webroot/index.php(57): Zend_Soap_AutoDiscover->setClass('TestService in /zend-test/Zend/Soap/Wsdl.php on line 443
The code is as following: <?php ini_set('soap.wsdl_cache_enabled', '0'); ini_set('soap.wsdl_cache_ttl', '0');
require_once "Zend/Loader.php"; Zend_Loader::registerAutoload();
class TestService { /** * @return test */ public function getTestObject() { return new Test(); }
/** * @return Test[] */ public function getDataArray() { $arrResult = array(); $arrResult[] = new Test(); $arrResult[] = new Test(); return $arrResult; } }
class Test { /** * @var int */ var $intTest = 5;
/** * @var string */ var $strTest;
/** * @var boolean */ var $bTest = true;
public function Test() { $this->intTest=7; $this->strTest = utf8_encode("ABCDE - Hello World - æøå ÆØÅ"); } }
if(isset($_REQUEST['wsdl'])) { $server = new Zend_Soap_AutoDiscover('Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex'); $server->setClass( 'TestService' ); $server->handle(); }
Why I experience the error I havent checked, but for some reason it tries to add the type "test" twice. If I remove the "getTestObject" method I get the following XML error instead: XML Parsing Error: prefix not bound to a namespace Location: http://address.local/?wsdl Line Number 2, Column 1364:
Comments
Posted by Benjamin Eberlei (beberlei) on 2008-11-12T16:21:06.000+0000
hello,
you actually found a list of bugs that are attached to this issue of having a complex type more than once per AutoDiscover process.
I'll look into them tomorrow morning and fix them, eventually merge them back to 1.7.
Posted by Benjamin Eberlei (beberlei) on 2008-11-13T08:51:57.000+0000
Issue is resolved, and will be included in 1.7, which will be released on monday.
Posted by Wil Sinclair (wil) on 2008-11-13T14:10:22.000+0000
Changing issues in preparation for the 1.7.0 release.
Posted by Wil Sinclair (wil) on 2008-12-01T13:50:45.000+0000
Updating these issues to mark them resolved for 1.7.1.