mam przygotowanie serwera SOAP i WSDL generowania moją pomocą kodu następująco:Zend Framework 2 SOAP autodiscover i złożone typy
//(... Controller action code ...)
if (key_exists('wsdl', $params)) {
$autodiscover = new AutoDiscover();
$autodiscover->setClass('WebServiceClass')
->setUri('http://server/webserver/uri');
$autodiscover->handle();
} else {
$server = new Server(null);
$server->setUri($ws_url);
$server->setObject($this->getServiceLocator()->get('MyController\Service\WebServiceClass'));
$server->handle();
}
//(... Controller action code ...)
Ale w jednym z mojej metody WebService Mam parametr typu Array, w której każdy element jest typu "MyOtherClass", jak następuje:
/**
* Add list of MyOtherClass items
*
* @param MyOtherClass[] $items
*
* @return bool
*/
function add($items) {
// Function code here
}
Kiedy próbuję wygenerować WSDL pojawia się błąd następująco:
PHP Warning: DOMDocument::loadXML(): Empty string supplied as input in /<zend framweork path>/Server/vendor/zendframework/zendframework/library/Zend/Soap/Server.php on line 734
Albo ten wyjątek:
Cannot add a complex type MyOtherClass[] that is not an object or where class could not be found in "DefaultComplexType" strategy.
Kiedy dodałem do mojego kodu tak:
//(...)
if (key_exists('wsdl', $params)) {
$autodiscover = new AutoDiscover();
$autodiscover->setClass('WebServiceClass');
$autodiscover->setUri($ws_url);
$complex_type_strategy = new \Zend\Soap\Wsdl\ComplexTypeStrategy\ArrayOfTypeComplex();
$complex_type_strategy->addComplexType('MyOtherClass');
$autodiscover->setComplexTypeStrategy($complex_type_strategy);
$autodiscover->handle();
} else {
//(...)
pojawia się komunikat o błędzie następująco:
Fatal error: Call to a member function getTypes() on a non-object in /<project dir>/vendor/zendframework/zendframework/library/Zend/Soap/Wsdl/ComplexTypeStrategy/AbstractComplexTypeStrategy.php on line 54
W życiorysie, pytanie : jak mogę rozpoznać WSDL nowego typu niestandardowego używanego jako parametr?
Dzięki
'MyOtherClass []' wygląda mi nie tak w kontekście php. Chciałbym spróbować utworzyć obiekt MyOtherClassCollection, który przechowuje elementy. – DanielKhan
'MyOtherClass []' definiuje tablicę obiektów MyOtherClass. Jest to całkowicie w porządku w PHP dla trybów Zend \ Soap \ AutoDiscover 'ArrayOfTypeSequence' oraz' ArrayOfTypeComplex'. –