SOAP-ERROR: Parsing WSDL: failed to load external entity
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://www.webservicex.net/globalweather.asmx?wsdl' : failed to load external entity "http://www.webservicex.net/globalweather.asmx?wsdl" in /www/wwwroot/xxxxx.com/23.php:8 Stack trace: #0 /www/wwwroot/xxxxx.com/23.php(8): SoapClient->SoapClient('http://www.webs...') #1 {main} thrown in /www/wwwroot/xxxxx.com/23.php on line 8
这个错误是我们ehr同步人员和部门信息接口报的错,直接访问WSDL也能正常返回
php请求接口FCOperate.asmx?WSDL 接口。这里需要注意升级php版本,尽可能升级的到php7.0
测试发现产生这个错误与PHP版本有关,版本高的不会出现这个问题。
解决方案:
1、修改服务器网关配置,就是OpenSSL,它是一种通信协议,改一发动全身,所以我没动服务器
2、修改PHP版本再测
3、也就是直接在代码处修改(推荐),代码如下:
$wsdl='http://你的地址/PSIGW/PeopleSoftServiceListeningConnector/PSFT_HR/HPS_HRIF001_OA_DEPT.1.wsdl';
$streamContext = array(stream_context_create(array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false
)
)));
$client = new SoapClient($wsdl, $streamContext);
$result=$client->__doRequest($xmldata,$wsdl,'HPS_HFIFOA_DEP_SRVACTN.v1',1,0);
return $result;
就是
这一句很关键。
这是我找到解决办法的地方:http://php.net/manual/en/migration56.openssl.php
更新日期2018-12-19:我前几天看日志上面一个接口通的,下面一个接口还是报这个错,代码一样的。于是我下面的代码改成就OK了:
$wsdl = 'http://地址/PSIGW/PeopleSoftServiceListeningConnector/PSFT_HR/HPS_HRIF001_OA_EMPL.1.wsdl';
/*$streamContext = array(stream_context_create(array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false
)
)));*/
$opts = array(
'ssl' => array('ciphers' => 'RC4-SHA', 'verify_peer' => false, 'verify_peer_name' => false)
);
$params = array('encoding' => 'UTF-8', 'soap_version' => SOAP_1_2, 'trace' => 1, 'exceptions' => 1, "connection_timeout" => 180, 'stream_context' => stream_context_create($opts));
$client = new SoapClient($wsdl, $params);
$result = $client->__doRequest($xmldata, $wsdl, 'HPS_HFIFOA_EMP_SRVACTN.v1', 1, 0);
return $result;
注意看上面红色部分