我想使用Zend_Soap返回一个对象。我也想要WSDL文件中给出的对象。但我不能让两者一起工作。它可能是其中之一。
1。 WSDL工作,但对象没有返回
如果在soap服务器脚本的函数的phpdoc中,我写了
@return Application_Model_Soap_Test
我可以在WSDL文件中看到它
<message name="getPostcodeOut">
<part name="return" type="tns:Application_Model_Soap_Test"/>
</message>
但是当我运行脚本时,它返回一个空类:
stdClass Object
(
)
2。获取对象,但错误的WSDL
如果我将服务器功能的phpdoc信息更改为
@return mixed Application_Model_Soap_Test
我通过信息获取了一个对象:
stdClass Object
(
[name] => Fred
[age] => 40
)
但WSDL文件错误
<message name="getPostcodeOut">
<part name="return" type="xsd:anyType"/>
</message>
有什么想法吗?感谢。
答案 0 :(得分:1)
您需要在客户端传递'classmap'选项变量。
关于选项数组中传递的'classmap'选项,请参见http://www.php.net/manual/en/soapclient.soapclient.php和http://www.php.net/manual/en/soapclient.soapclient.php。
基本上它应该是一个数组,将类映射到定义为WSDL文件中返回对象的类。
答案 1 :(得分:0)
您是否尝试关闭缓存?
In PHP how can you clear a WSDL cache?
我遇到了同样的问题。我做的每个请求都返回一个空的stdclass,即使WSDL是正确的。禁用缓存后,它对我来说很好。试一试。