原文链接:http://myitlife.blog.51cto.com/2289784/1529621
PHP在用SOAP协议做接口的时候,经常会碰到如下问题,不是不成功,而是偶尔不成功,实在让人费解!
ERR: SOAP-ERROR: Parsing WSDL: Couldn’t load from ‘http://www.xxxxx.com/member/member_sync.php?wsdl’ : failed to load external entity “http://www.xxxxx.com/member/member_sync.php?wsdl”
查找日志发现:
NOTIC: [2] SoapClient::SoapClient(): I/O warning : failed to load external entity “http://www.xxxxx.com/member/member_sync.php?wsdl” /home/wwwroot/default/xxxxx.com/App/Modules/Admin/Action/OrderAction.class.php 第 112 行.客户端$client = new SoapClient ( $url );创建SoapClient对象时出错!
网上查找很多资料,有开启selinux、关闭soap缓存、开启openssl等等答案,但尝试过后都不尽人意,现终极解决办法:
只需把php的客户端SoapClient的wsdl模式修改为non-wsdl模式,即可解决!
wsdl模式:
$url = “http://xxxxx.org/member/member_sync.php?wsdl”;
$client = new SoapClient ( $url );
non-wsdl模式:
$client = new SoapClient(null,array(‘location’=>’http://www.xxxxx.com/member/member_sync.php’,uri => ‘member_sync.php’));