SOAP 客户端接收空的标准类 [英] SOAP Client receiving empty stdclass

查看:27
本文介绍了SOAP 客户端接收空的标准类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不明白为什么我得到一个空的 stdclass 对象.

I don't understand why I am getting an empty stdclass object.

代码如下:

$client = new Zend_Soap_Client('http://urltocodethatgenerateswsdl?wsdl', $options);
$result = $client->sayHello(array( 'who' => 'Heidi'));
Zend_Debug::dump($client->getLastResponse());
Zend_Debug::dump($result);

这是我得到的 lastResponse:

Here's what I get for the lastResponse:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://urltocodethatgenerateswsdl">
    <SOAP-ENV:Body>
        <ns1:sayHelloResponse>
            <return>Say Hello Heidi</return>
        </ns1:sayHelloResponse>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

这是 $result 的转储

And here is the dump of $result

object(stdClass)#23 (0) {}

这是为什么?有人能解释一下吗?

Why is that? Can somebody explain?

更新:添加了 WSDL(由 Zend 使用 AutoDiscovery 自动生成)

<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://clxpreview.ch/index/soap" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="Service_Soap" targetNamespace="http://clxpreview.ch/index/soap">
<types>
    <xsd:schema targetNamespace="http://urltocodethatgenerateswsdl">
        <xsd:complexType name="User">
            <xsd:all>
                <xsd:element name="username" type="xsd:string" nillable="true"/>
                <xsd:element name="password" type="xsd:string" nillable="true"/>
            </xsd:all>
        </xsd:complexType>
    </xsd:schema>
</types>
<portType name="Service_SoapPort">
    <operation name="getSystemTime">
        <documentation>getSystemTime</documentation>
        <input message="tns:getSystemTimeIn"/>
        <output message="tns:getSystemTimeOut"/>
    </operation>
    <operation name="sayHello">
        <documentation>sayHello</documentation>
        <input message="tns:sayHelloIn"/>
        <output message="tns:sayHelloOut"/>
    </operation>
    <operation name="getUser">
        <documentation>setUser</documentation>
        <input message="tns:getUserIn"/>
        <output message="tns:getUserOut"/>
    </operation>
    <operation name="setUser">
        <documentation>setUser</documentation>
        <input message="tns:setUserIn"/>
        <output message="tns:setUserOut"/>
    </operation>
</portType>
<binding name="Service_SoapBinding" type="tns:Service_SoapPort">
    <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
    <operation name="getSystemTime">
        <soap:operation soapAction="http://urltocodethatgenerateswsdl#getSystemTime"/>
        <input>
            <soap:body use="literal" namespace="http://urltocodethatgenerateswsdl"/>
        </input>
        <output>
            <soap:body use="literal" namespace="http://urltocodethatgenerateswsdl"/>
        </output>
    </operation>
    <operation name="sayHello">
        <soap:operation soapAction="http://urltocodethatgenerateswsdl#sayHello"/>
        <input>
            <soap:body use="literal" namespace="http://urltocodethatgenerateswsdl"/>
        </input>
        <output>
            <soap:body use="literal" namespace="http://urltocodethatgenerateswsdl"/>
        </output>
    </operation>
    <operation name="getUser">
        <soap:operation soapAction="http://urltocodethatgenerateswsdl#getUser"/>
        <input>
            <soap:body use="literal" namespace="http://urltocodethatgenerateswsdl"/>
        </input>
        <output>
            <soap:body use="literal" namespace="http://urltocodethatgenerateswsdl"/>
        </output>
    </operation>
    <operation name="setUser">
        <soap:operation soapAction="http://urltocodethatgenerateswsdl#setUser"/>
        <input>
            <soap:body use="literal" namespace="http://urltocodethatgenerateswsdl"/>
        </input>
        <output>
            <soap:body use="literal" namespace="http://urltocodethatgenerateswsdl"/>
        </output>
    </operation>
</binding>
<service name="Service_SoapService">
    <port name="Service_SoapPort" binding="tns:Service_SoapBinding">
        <soap:address location="http://urltocodethatgenerateswsdl"/>
    </port>
</service>
<message name="getSystemTimeIn"/>
<message name="getSystemTimeOut">
    <part name="return" type="xsd:string"/>
</message>
<message name="sayHelloIn">
    <part name="who" type="xsd:string"/>
</message>
<message name="sayHelloOut">
    <part name="return" type="xsd:string"/>
</message>
<message name="getUserIn">
    <part name="uid" type="xsd:int"/>
</message>
<message name="getUserOut">
    <part name="return" type="tns:User"/>
</message>
<message name="setUserIn">
    <part name="user" type="tns:User"/>
</message>
<message name="setUserOut">
    <part name="return" type="xsd:string"/>
</message>
</definitions>

提前致谢

开尔文

推荐答案

我找到了它不工作的原因.我必须在配置中关闭缓存,并添加一个选项以在我提出的请求中不缓存.

I found the reason why it wasn't working. I had to turn off caching in the config and add an option to not cache in the request I made.

使用 ini_set 或修改 php.ini 禁用缓存:

Either disable caching by using ini_set, or by making a modification to your php.ini:

ini_set("soap.wsdl_cache_enabled", 0);

我还在请求中添加了以下选项参数:

I also added the following option parameter to my request:

array('cache_wsdl' => WSDL_CACHE_NONE)

这是我在 Stackoverflow 上找到的一篇文章:在 PHP 中如何清除 WSDL 缓存?

Here's an article I found on Stackoverflow: In PHP how can you clear a WSDL cache?

这篇关于SOAP 客户端接收空的标准类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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