PHP SoapClient __call()异常:SOAP不支持DTD

时间:2011-06-16 16:23:11

标签: php soap wsdl soap-client

这个是杀了我......

我正在学习用PHP开发SOAP服务器,而且我遇到了一个令人烦恼的问题,谷歌没有多大帮助,尽管对这个问题有很多打击......

使用我认为是一个好的WSDL实例化SOAP CLIENT后,第一次调用soap服务器上的现有函数会产生以下异常:

SoapFault Object
(
    [message:protected] => DTD are not supported by SOAP
    [string:private] => 
    [code:protected] => 0
    [file:protected] => /var/www/soapserver/soapServerTestClient.php
    [line:protected] => 7
    [trace:private] => Array
        (
            [0] => Array
                (
                    [function] => __call
                    [class] => SoapClient
                    [type] => ->
                    [args] => Array
                        (
                            [0] => testSoapService
                            [1] => Array
                                (
                                    [0] => TESTSTRING
                                )

                        )

                )

            [1] => Array
                (
                    [file] => /var/www/soapserver/soapServerTestClient.php
                    [line] => 7
                    [function] => testSoapService
                    [class] => SoapClient
                    [type] => ->
                    [args] => Array
                        (
                            [0] => TESTSTRING
                        )

                )

        )

    [faultstring] => DTD are not supported by SOAP
    [faultcode] => Client
    [faultcodens] => http://schemas.xmlsoap.org/soap/envelope/
)

转储__getLastRequest(),__ getLastResponse(),__ getLastRequestHeaders()和__getLastResponseHeaders()会产生完全EMPTY结果,因此实际上正在发送/请求NOTHING。

访问WSDL的链接按预期返回WSDL文件内容,我知道这是有效的,因为更改WSDL的路径会返回SOAP-ERROR: Parsing WSDL: Couldn't load异常,并将其放回实际的WSDL路径会生成异常上方。

肥皂服务器代码如下,但由于没有请求/响应,我不认为这是问题所在:

  

function testSoapService($ arg){       return''。$ arg。''; }

     

的ini_set( “soap.wsdl_cache_enabled”,   “0”); //禁用WSDL缓存以便您   可以毫不费力地测试wsdl的变化;   在设置WSDL时注释掉。 $服务器   = new SoapServer(“”);   $服务器 - >调用addFunction( “testSoapService”);   $服务器 - >手柄();

搜索谷歌,一群人说这是一个糟糕的wsdl路径(在这种情况下不这么认为),或者服务器返回错误种类(404等)的HTML页面的事实网络服务器,我也不认为是这种情况,因为请求/响应是空的。

这是WSDL内容的副本,以防它有用:

<?xml version="1.0" encoding="UTF-8"?>

<wsdl:types>

    <schema xmlns:rns="http://soap.jrimer-amp64/" xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://soap.jrimer-amp64/" version="1.0" elementFormDefault="unqualified" attributeFormDefault="unqualified">
        <complexType name="testSoapServiceRequest">
            <sequence>
                <element name="testKey" type="string"/>
            </sequence>
        </complexType>
        <complexType name="testSoapServiceResponse">
            <sequence>
                <element name="result" type="string" minOccurs="1"/>
                <element name="retStatus" type="rns:returnStatus"/>
            </sequence>
        </complexType>
        <complexType name="returnStatus">
            <sequence>
                <element name="errorMessage" type="string" minOccurs="0"/>
                <element name="errorCode" type="string" minOccurs="0"/>
            </sequence>
            <attribute name="success" type="boolean"/>
        </complexType>
        <element name="addRouterToCustomerAccountRequest" type="rns:addRouterToCustomerAccountRequest"/>
        <element name="addRouterToCustomerAccountResponse" type="rns:addRouterToCustomerAccountResponse"/>
    </schema>

</wsdl:types>


<wsdl:service name="XxxxxxSvc">

    <wsdl:port name="XxxxxxSvc-Endpoint0" binding="tns:XxxxxxSvc-Endpoint0Binding">
        <soap:address location="http://soap.jrimer-amp64"/>
    </wsdl:port>

</wsdl:service>


<wsdl:portType name="portType">

    <wsdl:operation name="testSoapService">
        <wsdl:input message="tns:testSoapServiceRequest"/>
        <wsdl:output message="tns:testSoapServiceResponse"/>
    </wsdl:operation>

</wsdl:portType>


<wsdl:binding name="XxxxxxSvc-Endpoint0Binding" type="tns:portType">

    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />

    <wsdl:operation name="testSoapService">
        <soap:operation style="document" soapAction="http://soap.jrimer-amp64/XxxxxxSvc-SoapServer.php"/>
        <wsdl:input>
            <soap:body use="literal" parts="parameters"/>
        </wsdl:input>
        <wsdl:output>
            <soap:body use="literal" parts="parameters"/>
        </wsdl:output>
    </wsdl:operation>

</wsdl:binding>


<wsdl:message name="testSoapServiceRequest">
    <wsdl:part name="parameters" element="ns0:testSoapServiceRequest"/>
</wsdl:message>


<wsdl:message name="testSoapServiceResponse">
    <wsdl:part name="parameters" element="ns0:testSoapServiceResponse"/>
</wsdl:message>

有什么想法吗?

1 个答案:

答案 0 :(得分:5)

  

转储__getLastRequest(),   __getLastResponse(),__ getLastRequestHeaders()和__getLastResponseHeaders()完全产生EMPTY结果,所以没什么   实际上是发送/请求它   出现。

您是否设置了trace选项设置为true的客户端?您需要在dumpLastXXX方法起作用之前执行此操作。