php – 接收空stdclass的SOAP客户端

发布时间:2022-04-30 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了php – 接收空stdclass的SOAP客户端脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
我不明白为什么我得到一个空的stdclass对象.

这是代码

$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得到的:

<?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的转储

object(stdClass)#23 (0) {}

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

更新:添加了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>

提前致谢

解决方法

找到了它无法正常工作的原因.我不得不关闭配置中的缓存并添加一个选项,以便不在我发出的请求中缓存.

通过使用ini_set禁用缓存,或者通过修改PHP.ini来禁用缓存:

ini_set("soap.wsdl_cache_enabled",0);

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

array('cache_wsdl' => WSDL_CACHE_NONE)

这是我在Stackoverflow上发现的一篇文章
In PHP how can you clear a WSDL cache?

脚本宝典总结

以上是脚本宝典为你收集整理的php – 接收空stdclass的SOAP客户端全部内容,希望文章能够帮你解决php – 接收空stdclass的SOAP客户端所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。