简体   繁体   English

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

[英]PHP SoapClient __call() exception: DTD are not supported by SOAP

This one is killing me... 这个杀了我...

I'm learning to develop SOAP servers in PHP at the moment, and I'm running into an annoying problem and Google isn't helping much, despite plenty of hits on the problem in question... 目前,我正在学习用PHP开发SOAP服务器,尽管遇到了很多问题,但我遇到了一个令人烦恼的问题,而Google并没有太大帮助...

After instantiating the SOAP CLIENT using a what I believe to be a good WSDL, the first call to an existing function on the soap server is generating the following Exception: 在使用我认为是好的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/
)

Dumping the __getLastRequest(), __getLastResponse(), __getLastRequestHeaders(), and __getLastResponseHeaders() yield completely EMPTY results, so NOTHING is actually being sent/requested it appears. 转储__getLastRequest(),__getLastResponse(),__getLastRequestHeaders()和__getLastResponseHeaders()会产生完全空的结果,因此实际上没有发送/请求。

Visiting the link to the WSDL returns the WSDL file contents as expected, and I know this works because altering the path to the WSDL returns a SOAP-ERROR: Parsing WSDL: Couldn't load exception, and putting it back to the actual WSDL path generates the exception above. 访问WSDL的链接将按预期返回WSDL文件的内容,我知道这是可行的,因为更改WSDL的路径将返回SOAP-ERROR: Parsing WSDL: Couldn't load异常,并将其放回实际的WSDL路径生成上面的异常。

the soap server code is below, but since there's no request/response I don't think it's the issue: soap服务器代码在下面,但是由于没有请求/响应,所以我认为这不是问题所在:

function testSoapService($arg) { return ''.$arg.''; 函数testSoapService($ arg){return``。$ arg。''; } }

ini_set("soap.wsdl_cache_enabled", "0"); ini_set(“ soap.wsdl_cache_enabled”,“ 0”); // disabling WSDL cache so you can test wsdl changes without hassle; //禁用WSDL缓存,以便您可以轻松测试wsdl更改; comment out when WSDL is set. 设置WSDL时注释掉。 $server = new SoapServer(""); $ server = new SoapServer(“”); $server->addFunction("testSoapService"); $ server-> addFunction(“ testSoapService”); $server->handle(); $ server-> handle();

Searching google, a mix of people are saying it's either a bad wsdl path (don't think so in this case), or the fact that the server is returning HTML pages of the error variety (404, etc) from the webserver, which I also don't think is the case because the requests/responses are empty. 在搜寻google时,很多人说这是错误的wsdl路径(在这种情况下不要这样),或者服务器从网络服务器返回错误种类繁多的HTML页面(404等)的事实。我也不认为是这种情况,因为请求/响应为空。

Here's a copy of the WSDL contents, just in case it's useful: 这是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>

Any ideas? 有任何想法吗?

Dumping the __getLastRequest(), __getLastResponse(), __getLastRequestHeaders(), and __getLastResponseHeaders() yield completely EMPTY results, so NOTHING is actually being sent/requested it appears. 转储__getLastRequest(),__getLastResponse(),__getLastRequestHeaders()和__getLastResponseHeaders()会产生完全空的结果,因此实际上没有发送/请求。

Have you set up your client with the trace options set to true ? 您是否已将trace选项设置为true设置客户端? You need to do this before the dumpLastXXX methods will work. 在dumpLastXXX方法起作用之前,您需要执行此操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM