问题详细情况如下,php SOAP接口,间歇性出现Soap WSDL Error - "failed to load external entity" 这个错误。问题的关键是“间歇性”,如果一直报错就比较容易检查错误。
网络上的解决方案,要么是开启openssl,要么是改成no wsdl模式来做,以上方法都不能解决我的问题。
最后,在zend的官方论坛上找到了一个方法,并且来源指向是php手册,还是那句话,碰到问题多看手册。ORZ 手册!
If libxml_disable_entity_loader() has been called already, add before each SoapClient instantiation:
libxml_disable_entity_loader(false);
在所有SOAPClient初始化前(页面顶部),加上这句 libxml_disable_entity_loader(false);
如下:
function __construct(){
libxml_disable_entity_loader(false); //此处
$this->Service = new SoapClient(C("FileServer") . "?WSDL");
//$this->Service = null;
$this->Service->defdecoding = "utf-8";
}
测试100次以上,不再出现问题。
原文链接 http://forums.zend.com/viewtopic.php?f=8&t=116708#p225468
本文解决了PHP SOAP接口中偶尔出现的SoapWSDLError-failedtoloadexternalentity错误。通过在SOAPClient实例化前调用libxml_disable_entity_loader(false)的方法,成功解决了这一间歇性问题。

7151

被折叠的 条评论
为什么被折叠?



