[英]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.