SOAP-ERROR: Parsing WSDL: failed to load external entity怎么办?

SOAP-ERROR: Parsing WSDL: failed to load external entity怎么办?_第1张图片

这个错误是我们ehr同步人员和部门信息接口报的错,直接访问WSDL也能正常返回

SOAP-ERROR: Parsing WSDL: failed to load external entity怎么办?_第2张图片

测试发现产生这个错误与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;

就是

SOAP-ERROR: Parsing WSDL: failed to load external entity怎么办?_第3张图片

这一句很关键。 

这是我找到解决办法的地方: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;

 

你可能感兴趣的:(php,linux)