SOAP错误:编码:是否违反编码规则?

| 我正在尝试使用Yii提供Web服务。自动生成的wsdl在下面。我可以从命令行成功使用Web服务,但是通过Web浏览器,我得到了
SOAP-ERROR: Encoding: Violation of encoding rules
我是SOAP的新手,所以不确定如何调试问题。这是我用来使用Web服务的PHP代码:
<?php
    $client=new SoapClient(\'{url omitted for security}\',
        array(\'trace\'=>1,\'exceptions\'=>1));
    try {
        $result = $client->getPerson(90043412);
        var_dump($result);
    } catch (SoapFault $fault) {
        echo $fault->getMessage() . \'<br />\';
        echo \'REQUEST <br />\';
        echo \'<pre>\';
        echo $client->__getLastRequestHeaders();
        echo $client->__getLastRequest();
        echo \'</pre>\';
        echo \'RESPONSE <br />\';
        echo \'<pre>\';
        echo $client->__getLastResponseHeaders();
        echo $client->__getLastResponse();
        echo \'</pre>\';
        echo \'TRACE <br />\';
        echo \'<pre>\';
        var_dump($fault->getTrace());
        echo \'</pre>\';
    }
?>
这是WSDL:
<?xml version=\"1.0\" encoding=\"UTF-8\"?> 
<definitions xmlns=\"http://schemas.xmlsoap.org/wsdl/\" xmlns:tns=\"urn:PersonControllerwsdl\" xmlns:soap=\"http://schemas.xmlsoap.org/wsdl/soap/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:wsdl=\"http://schemas.xmlsoap.org/wsdl/\" xmlns:soap-enc=\"http://schemas.xmlsoap.org/soap/encoding/\" name=\"PersonController\" targetNamespace=\"urn:PersonControllerwsdl\">
    <wsdl:types>
        <xsd:schema targetNamespace=\"urn:PersonControllerwsdl\">
            <xsd:complexType name=\"Person\">
                <xsd:all>
                    <xsd:element name=\"PIDM\" type=\"xsd:integer\"/>
                    <xsd:element name=\"FirstName\" type=\"xsd:string\"/>
                    <xsd:element name=\"MiddleName\" type=\"xsd:string\"/>
                    <xsd:element name=\"LastName\" type=\"xsd:string\"/>
                    <xsd:element name=\"PrefFirstName\" type=\"xsd:string\"/>
                    <xsd:element name=\"CPOBox\" type=\"xsd:string\"/>
                    <xsd:element name=\"Classification\" type=\"xsd:string\"/>
                    <xsd:element name=\"Email\" type=\"xsd:string\"/>
                    <xsd:element name=\"PhotoFile\" type=\"xsd:string\"/>
                </xsd:all>
            </xsd:complexType>
        </xsd:schema>
    </wsdl:types>
    <wsdl:message name=\"getPersonRequest\">
        <wsdl:part name=\"PIDM\" type=\"xsd:int\"/>
    </wsdl:message>
    <wsdl:message name=\"getPersonResponse\">
        <wsdl:part name=\"return\" type=\"tns:Person\"/>
    </wsdl:message>
    <wsdl:portType name=\"PersonControllerPortType\">
        <wsdl:operation name=\"getPerson\">
            <wsdl:documentation></wsdl:documentation>
            <wsdl:input message=\"tns:getPersonRequest\"/>
            <wsdl:output message=\"tns:getPersonResponse\"/>
        </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name=\"PersonControllerBinding\" type=\"tns:PersonControllerPortType\">
        <soap:binding style=\"rpc\" transport=\"http://schemas.xmlsoap.org/soap/http\"/>
        <wsdl:operation name=\"getPerson\">
            <soap:operation soapAction=\"urn:PersonControllerwsdl#getPerson\" style=\"rpc\"/>
            <wsdl:input>
                <soap:body use=\"encoded\" namespace=\"urn:PersonControllerwsdl\" encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"/>
            </wsdl:input>
            <wsdl:output>
                <soap:body use=\"encoded\" namespace=\"urn:PersonControllerwsdl\" encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"/>
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name=\"PersonControllerService\">
        <wsdl:port name=\"PersonControllerPort\" binding=\"tns:PersonControllerBinding\">
            <soap:address location=\"https://localhost/whoswho/person/service?ws=1\"/>
        </wsdl:port>
    </wsdl:service>
</definitions> 
    
已邀请:
SOAP请求的格式可能不正确。我一直在使用SoapUI,默认情况下,所有参数最初都设置为\'?\',如果您发出此请求,PHP将失败并使用您报告的错误消息进行响应。您不能捕获此错误,因为不会引发异常,这是因为这是一个致命错误。 您可以使用set_error_handler()函数http://php.net/manual/en/function.set-error-handler.php来针对这种情况设置自己的错误处理程序     
我正在努力将PHP版本更新为5.6.26,并且此错误在我的Web服务调用中弹出。一段时间后,我发现此问题可以在PHP.ini文件中的以下行中修复:
;always_populate_raw_post_data = -1
查看文档,此版本不建议使用此选项。 我希望此评论可以节省时间。     
如果我将消费脚本托管在与托管Web服务的服务器不同的服务器上,则它可以正常运行。由于Web服务是为机器与机器之间的通信而设计的,而不是机器自言自语的,因此这似乎是一个适当的解决方案。     
我知道这是一个旧线程,但是如果您像尝试解决此问题那样遇到它,则可以尝试将soap:address设置为http://127.0.0.1而不是http:// localhost。我已经在其他一些论坛上对此有所帮助。     

要回复问题请先登录注册