用SOAP做接口开发的时候间歇性碰到一个错误:
PHP Fatal error: SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://test.com/openService/test.wsdl' : failed to load external entity "http://test.com/openService/test.wsdl"
处理方法:
在php手册中可以找到一个方法,连接:http://php.net/manual/es/soapclient.soapclient.php
内容如下:
Note that if libxml_disable_entity_loader() has been called, you cannot specify a WSDL file - you'll get an error that PHP "failed to load external entity".
To resolve this, add
<?php
libxml_disable_entity_loader(false);
?>
Above any calls to instantiate SoapClient.
在所有SOAPClient初始化前(页面顶部),加上这句 libxml_disable_entity_loader(false);