doucheng1891 2010-05-26 18:34
浏览 33
已采纳

Zend_Soap_AutoDiscover和PHP名称空间

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

  • 写回答

1条回答 默认 最新

  • doujiao7679 2010-09-21 19:27
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题