使用 Zend_Soap 返回对象
我想使用 Zend_Soap 返回一个对象。我还想要 WSDL 文件中给出的对象。但我无法让两者一起工作。要么是其中之一,要么是另一个。
1. WSDL 工作,但对象没有返回
如果在肥皂服务器脚本上我的函数的 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>
有什么想法吗?谢谢。
I would like to return an object using Zend_Soap. I also want the object given in the WSDL file. But I can't get both to work together. It's either one or the other.
1. WSDL working, but object not returning
If in the phpdoc of my function on the soap server script, I write
@return Application_Model_Soap_Test
I can see it in the WSDL file
<message name="getPostcodeOut">
<part name="return" type="tns:Application_Model_Soap_Test"/>
</message>
but when I run the script, it returns an empty class:
stdClass Object
(
)
2. Get object, but wrong WSDL
If I change the server function's phpdoc info to
@return mixed Application_Model_Soap_Test
I get an object back with info:
stdClass Object
(
[name] => Fred
[age] => 40
)
but the WSDL file is wrong
<message name="getPostcodeOut">
<part name="return" type="xsd:anyType"/>
</message>
Any ideas? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要在客户端中传递“classmap”选项变量。
请参阅 http://www.php.net/manual/en/soapclient.soapclient .php 和 http://www.php.net/manual/ en/soapclient.soapclient.php 关于选项数组中传递的 'classmap' 选项。
基本上它应该是一个数组,将您的类映射到 WSDL 文件中定义为返回对象的类。
You need to pass a 'classmap' option variable in the client.
See both http://www.php.net/manual/en/soapclient.soapclient.php and http://www.php.net/manual/en/soapclient.soapclient.php about the 'classmap' option passed in the option array.
Basically it should be an array mapping your classes to the classes defined as the returned objects in the WSDL file.
您是否尝试关闭缓存?
在 PHP 中如何清除 WSDL 缓存?
我也有同样的问题。我提出的每个请求都返回一个空的 stdclass,即使 WSDL 是正确的。禁用缓存后,它对我来说效果很好。尝试一下。
Did you try to turn off caching?
In PHP how can you clear a WSDL cache?
I had the same problem. Every request I made returned me an empty stdclass, even though the WSDL was correct. After disabling caching it worked fine for me. Give it a try.