簡體   English   中英

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

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

這個殺了我...

目前,我正在學習用PHP開發SOAP服務器,盡管遇到了很多問題,但我遇到了一個令人煩惱的問題,而Google並沒有太大幫助...

在使用我認為是好的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()會產生完全空的結果,因此實際上沒有發送/請求。

訪問WSDL的鏈接將按預期返回WSDL文件的內容,我知道這是可行的,因為更改WSDL的路徑將返回SOAP-ERROR: Parsing WSDL: Couldn't load異常,並將其放回實際的WSDL路徑生成上面的異常。

soap服務器代碼在下面,但是由於沒有請求/響應,所以我認為這不是問題所在:

函數testSoapService($ arg){return``。$ arg。''; }

ini_set(“ soap.wsdl_cache_enabled”,“ 0”); //禁用WSDL緩存,以便您可以輕松測試wsdl更改; 設置WSDL時注釋掉。 $ server = new SoapServer(“”); $ server-> addFunction(“ testSoapService”); $ server-> handle();

在搜尋google時,很多人說這是錯誤的wsdl路徑(在這種情況下不要這樣),或者服務器從網絡服務器返回錯誤種類繁多的HTML頁面(404等)的事實。我也不認為是這種情況,因為請求/響應為空。

這是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>

有任何想法嗎?

轉儲__getLastRequest(),__getLastResponse(),__getLastRequestHeaders()和__getLastResponseHeaders()會產生完全空的結果,因此實際上沒有發送/請求。

您是否已將trace選項設置為true設置客戶端? 在dumpLastXXX方法起作用之前,您需要執行此操作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM