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.

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

报告相同问题?

悬赏问题

  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源