dongyimeng3764 2011-06-16 16:23
浏览 165
已采纳

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

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...

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:

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.

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.

the soap server code is below, but since there's no request/response I don't think it's the issue:

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

ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache so you can test wsdl changes without hassle; comment out when WSDL is set. $server = new SoapServer(""); $server->addFunction("testSoapService"); $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.

Here's a copy of the WSDL contents, just in case it's useful:

<?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?

  • 写回答

1条回答 默认 最新

  • douhuan9289 2011-06-16 16:30
    关注

    Dumping the __getLastRequest(), __getLastResponse(), __getLastRequestHeaders(), and __getLastResponseHeaders() yield completely EMPTY results, so NOTHING is actually being sent/requested it appears.

    Have you set up your client with the trace options set to true? You need to do this before the dumpLastXXX methods will work.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图2.0 版本点聚合中Marker的位置无法实时更新,如何解决呢?
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题