提问人:AndyW 提问时间:11/8/2023 更新时间:11/8/2023 访问量:25
升级到 PHP 8.2 会导致 CRITICAL Uncaught SoapFault 异常:[WSDL] SOAP-ERROR:解析 WSDL:...无法加载外部实体
Upgrading to PHP 8.2 causes CRITICAL Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: ... failed to load external entity
问:
升级到 PHP 8.2 时,我们的一个 soap 连接开始出现以下错误。
2023-11-08T11:25:35+00:00 CRITICAL Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://example.com/example.asmx?WSDL' : failed to load external entity "https://example.com/example.asmx?WSDL"
回滚到 PHP 8.1 解决了这个问题,但系统的其他方面很快就会需要 8.2。
我们在网上尝试了各种解决方案,更改了代码和连接配置,以及这篇文章中的所有内容: SOAP PHP错误解析WSDL:无法加载外部实体?
我们正在连接的服务器使用自签名证书,我认为这是问题的根源,但这不是我们可以更改的。
这是我们当前的代码,在 PHP 8.1 中运行良好:
<?php
class MySoapClient extends \SoapClient
{
/**
*/
public function __construct()
{
$options = array (
'local_cert' => 'client_ssl.pem',
'passphrase' => 'xxxxxxxxxxxx',
'features' => 1,
'user_agent' => 'PHPSoapClient',
'cache_wsdl' => WSDL_CACHE_MEMORY,
'encoding' => 'UTF-8',
'verifypeer' => false,
'verifyhost' => false,
'soap_version' => SOAP_1_2,
'trace' => 1,
'exceptions' => true,
'connection_timeout' => 180,
'stream_context' => stream_context_create(
array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true,
'user_agent' => 'PHPSoapClient'
)
))
);
if (!$wsdl) {
$wsdl = 'https://example.com/example.asmx?WSDL';
}
parent::__construct($wsdl, $options);
}
/**
* @param GetCatalog $parameters
* @return GetCatalogResponse
*/
public function GetCatalog(GetCatalog $parameters)
{
return $this->__soapCall('GetCatalog', array($parameters));
}
}
答: 暂无答案
评论
$this->__soapCall('GetCatalog', [[$parameters]];
$this->__soapCall('GetCatalog', [(array)$parameters)];