Note that there are some explanatory texts on larger screens.

plurals
  1. POZend Framework 2 SOAP AutoDiscover and complex types
    primarykey
    data
    text
    <p>I'm preparing the SOAP server and generating my WSDL using the follow code:</p> <pre><code>//(... Controller action code ...) if (key_exists('wsdl', $params)) { $autodiscover = new AutoDiscover(); $autodiscover-&gt;setClass('WebServiceClass') -&gt;setUri('http://server/webserver/uri'); $autodiscover-&gt;handle(); } else { $server = new Server(null); $server-&gt;setUri($ws_url); $server-&gt;setObject($this-&gt;getServiceLocator()-&gt;get('MyController\Service\WebServiceClass')); $server-&gt;handle(); } //(... Controller action code ...) </code></pre> <p>But in one of my WebService method I have a parameter of type Array in which each element is of type "MyOtherClass", like follows:</p> <pre><code> /** * Add list of MyOtherClass items * * @param MyOtherClass[] $items * * @return bool */ function add($items) { // Function code here } </code></pre> <p>When I try to generate the WSDL I get the follow error:</p> <pre><code>PHP Warning: DOMDocument::loadXML(): Empty string supplied as input in /&lt;zend framweork path&gt;/Server/vendor/zendframework/zendframework/library/Zend/Soap/Server.php on line 734 </code></pre> <p>Or this Exception:</p> <pre><code>Cannot add a complex type MyOtherClass[] that is not an object or where class could not be found in "DefaultComplexType" strategy. </code></pre> <p>When I added to my code something like this:</p> <pre><code>//(...) if (key_exists('wsdl', $params)) { $autodiscover = new AutoDiscover(); $autodiscover-&gt;setClass('WebServiceClass'); $autodiscover-&gt;setUri($ws_url); $complex_type_strategy = new \Zend\Soap\Wsdl\ComplexTypeStrategy\ArrayOfTypeComplex(); $complex_type_strategy-&gt;addComplexType('MyOtherClass'); $autodiscover-&gt;setComplexTypeStrategy($complex_type_strategy); $autodiscover-&gt;handle(); } else { //(...) </code></pre> <p>I get the follow error message:</p> <pre><code>Fatal error: Call to a member function getTypes() on a non-object in /&lt;project dir&gt;/vendor/zendframework/zendframework/library/Zend/Soap/Wsdl/ComplexTypeStrategy/AbstractComplexTypeStrategy.php on line 54 </code></pre> <p>In resume, the question is: how can I make aware the WSDL of the new Custom Type used as parameter?</p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload