使用Zend_Soap返回对象 [英] Return object with Zend_Soap

查看:103
本文介绍了使用Zend_Soap返回对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Zend_Soap返回一个对象.我还想要WSDL文件中给定的对象.但是我不能让两者一起工作.可以是另一种.

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工作正常,但对象未返回

如果在soap服务器脚本上我函数的phpdoc中,我写

If in the phpdoc of my function on the soap server script, I write

 @return Application_Model_Soap_Test

我可以在WSDL文件中看到它

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.获取对象,但错误的WSDL

如果我将服务器功能的phpdoc信息更改为

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
)

但是WSDL文件错误

<message name="getPostcodeOut">
    <part name="return" type="xsd:anyType"/>
</message>

有什么想法吗?谢谢.

推荐答案

您需要在客户端中传递"classmap"选项变量.

You need to pass a 'classmap' option variable in the client.

请同时参见 http://www.php.net/manual/zh/soapclient.soapclient.php http://www.php.net/manual/en/soapclient.soapclient.php 关于在选项数组中传递的"classmap"选项.

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.

基本上,它应该是一个数组,将您的类映射到WSDL文件中定义为返回对象的类.

Basically it should be an array mapping your classes to the classes defined as the returned objects in the WSDL file.

这篇关于使用Zend_Soap返回对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆