Note that there are some explanatory texts on larger screens.

plurals
  1. POZend_Soap_AutoDiscover and PHP namespaces
    text
    copied!<p>I'm using namespaces in PHP for the first time in an application that provides a web service via Zend_Soap, and I'm running into a problem with the autodiscover feature. I have code something like this:</p> <pre><code>$autodiscoverObj = new Zend_Soap_AutoDiscover(); $autodiscoverObj-&gt;setClass('My\\Namespace\\MyClass'); </code></pre> <p>And I'm getting errors like this, "Zend_Soap_Wsdl_Exception: Cannot add a complex type MyClass that is not an object or where class could not be found".</p> <p>If I leave off the namespace portion of the setClass() value, as in:</p> <pre><code>$autodiscoverObj-&gt;setClass('MyClass'); </code></pre> <p>I get, "Zend_Server_Reflection_Exception: Invalid class or object passed to attachClass()', so it would appear that including the namespace as I did is correct.</p> <p>In trying to fix the WSDL exception, I noticed that, regardless of how I reference my class in the setClass() method, the Zend framework as passing the class to my autoload function sans namespace. Digging a little further, I see a chain of methods in the framework, starting with setClass() itself, that have an optional namespace parameter, but don't use it (they're even labeled "Not Used").</p> <p>My next thought was to use the setClassmap(), but, although that's available in the Zend_Soap_Server class, it's not available in the Zend_Soap_AutoDiscover class, IMO a definite <a href="http://framework.zend.com/issues/browse/ZF-8070" rel="nofollow noreferrer">bug that's already been filed by someone else</a>.</p> <p>Is the Zend framwork, and specifically, the SOAP component of same, simply incompatible with namespaces? If not, how do I create a SOAP service that uses classes from other namespaces?</p> <p>Version info:</p> <p>PHP: 5.3.0 Zend Framework: 1.9.8</p>
 

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