views:

89

answers:

1

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:

$autodiscoverObj = new Zend_Soap_AutoDiscover();
$autodiscoverObj->setClass('My\\Namespace\\MyClass');

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".

If I leave off the namespace portion of the setClass() value, as in:

$autodiscoverObj->setClass('MyClass');

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.

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").

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 bug that's already been filed by someone else.

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?

Version info:

PHP: 5.3.0 Zend Framework: 1.9.8

A: 

Zend Framework 1.x doesn't support PHP 5.3's namespaces. You would have to wait for Zend Framework 2, or do not use namespaces for Soap service classes.

bouke
Yeah, that was my conclusion as well. It would be helpful if they'd make that explicit, however.
mr. w