Zend Soap客户端返回null,最后一个响应为有效的XML


Zend Soap Client returns null with valid XML last response

我在尝试使用PHP访问自己的PHP Soap Service时遇到问题。我将Zend_Soap用于客户端和服务器。

基本上,我从客户端得到的结果是null。但是,如果我查看最后一个响应,它包含预期的、正确的XML。因此,客户端无法将xml转换为php对象(在我的测试用例中,是一个简单的int)以供使用。

我的wsdl看起来像这个

<definitions name="SOAP_Model_soaphandler" targetNamespace="http://website.com/appldev/applications/public/SOAP/index/soap">
    <types>
        <xsd:schema targetNamespace="http://website.com/appldev/applications/public/SOAP/index/soap"/>
    </types>
    <portType name="SOAP_Model_soaphandlerPort">
        <operation name="test">
            <documentation>Returns list of all products in database</documentation>
            <input message="tns:testIn"/>
            <output message="tns:testOut"/>
        </operation>
        <operation name="test2">
            <documentation>Adds new product to database</documentation>
            <input message="tns:test2In"/>
            <output message="tns:test2Out"/>
        </operation>
    </portType>
    <binding name="SOAP_Model_soaphandlerBinding" type="tns:SOAP_Model_soaphandlerPort">
        <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
        <operation name="test">
            <soap:operation soapAction="http://website.com/appldev/applications/public/SOAP/index/soap#test"/>
            <input>
                <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://website.com/appldev/applications/public/SOAP/index/soap"/>
            </input>
            <output>
                <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://website.com/appldev/applications/public/SOAP/index/soap"/>
            </output>
        </operation>
        <operation name="test2">
            <soap:operation soapAction="http://website.com/appldev/applications/public/SOAP/index/soap#test2"/>
            <input>
                <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://website.com/appldev/applications/public/SOAP/index/soap"/>
            </input>
            <output>
                <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://website.com/appldev/applications/public/SOAP/index/soap"/>
            </output>
        </operation>
    </binding>
    <service name="SOAP_Model_soaphandlerService">
        <port name="SOAP_Model_soaphandlerPort" binding="tns:SOAP_Model_soaphandlerBinding">
            <soap:address location="http://website.com/appldev/applications/public/SOAP/index/soap"/>
        </port>
    </service>
    <message name="testIn"/>
    <message name="testOut">
        <part name="return" type="xsd:int"/>
    </message>
    <message name="test2In">
        <part name="id" type="xsd:int"/>
    </message>
    <message name="test2Out">
        <part name="return" type="soap-enc:Array"/>
    </message>
</definitions>

我的回复看起来像这个

<env:envelope xmlns:enc="http://www.w3.org/2003/05/soap-encoding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns1="http://website.com/appldev/applications/public/SOAP/index/soap" xmlns:env="http://www.w3.org/2003/05/soap-envelope">
    <env:body xmlns:rpc="http://www.w3.org/2003/05/soap-rpc">
        <ns1:testresponse env:encodingstyle="http://www.w3.org/2003/05/soap-encoding">
            <rpc:result>return</rpc:result>
            <return xsi:type="xsd:int">7</return>
        </ns1:testresponse>
    </env:body>
</env:envelope>

但是

$result=$client->test(); 
var_dump($result);

输出NULL。

有什么想法吗?对我来说,它似乎应该起作用,但我不是肥皂客户端如何工作的专家。也许是名称空间或其他什么问题?我真的不知道。看起来它应该工作得很好。作为参考,我遵循了以下指南来启动和运行:

http://www.ibm.com/developerworks/webservices/library/x-zsoap/index.html

我想我总是可以手动从xml中获取响应,但我希望弄清楚为什么客户端不为我这样做。

您应该尝试删除soap临时文件:/tmp/wsdl*,然后重新启动Web服务器。希望得到帮助。

这有点晚了,但只是为了记录验证服务类中方法的声明,注释应该是这样的

/***服务**@param type$varname*@返回类型*/

必须有/**和一个空格,然后是其余空格。否则将返回null。

祝你好运!