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

18,341

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.

Share:
18,341
Rimer
Author by

Rimer

I like to code.

Updated on November 20, 2022

Comments

  • Rimer
    Rimer over 1 year

    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?

    • ben
      ben almost 13 years
      What do you see when you visit the WSDL with a browser?
  • Rimer
    Rimer almost 13 years
    You rock so hard I can feel it through the net. My URL for the service must be wrong because it's not going to the server code, but the index.php code at the same path... Thanks for the assist! ...To be clearer, setting trace on allowed me to see the contents of the request and response, which are no longer empty values when trace is set to true!
  • Robin
    Robin almost 13 years
    You're welcome :-). BTW, be aware that the PHP SOAP server implementation is buggy at best, it's just about usable, but be prepared for issues. Here's one that I came across whilst working on a SOAP server: bugs.php.net/bug.php?id=49169