我最近将我的开发环境从 Windows 10 更改为 Ubuntu 16.04(在 vmware 播放器中虚拟)。从那以后,我遇到了 PHP SoapClient 调用的问题。以下脚本在 Windows 10 (XAMPP) 下运行良好,也可以在我的在线服务器(Ubuntu 下的 Plesk-Onyx)上运行,但不能在 VM 中运行。
<?
ini_set ('soap.wsdl_cache_enabled', 0);
ini_set ('soap.wsdl_cache_ttl', 0);
$wsdl_file = 'soap/stage.wsdl';
$soap_param = array (
'location' => 'https://.../Service.asmx',
'local_cert' => 'soap/stage.pem',
'login' => 'USERNAME',
'password' => 'PASSWORD',
'soap_version' => SOAP_1_2,
'exceptions' => True,
'trace' => 1,
'connection_timeout' => 15
);
try {
$soap_client = new SoapClient ($wsdl_file, $soap_param);
$soap_client -> __call ('SOME_FUNCTION', array ()); //failing
} catch (Exception $e) {
echo $e -> getMessage ().'<br>';
}
?>
该行$soap_client -> __call ('SOME_FUNCTION', array ());
抛出错误消息:Could not connect to host
我尝试了在互联网上找到的各种修复程序,但没有任何效果。来宾和主机上的 SELinux 和防火墙被禁用。我错过了什么?提前致谢。
更新:
我还没有找到解决办法。但是通过检查发送的请求(使用$soap_client -> __getLastRequest ()
and $soap_client -> __getLastRequestHeaders ()
),请求标头中似乎缺少以下信息:
Host: SERVICE_HOST
Connection: Keep-Alive
User-Agent: PHP-SOAP/7.1.1
Content-Type: application/soap+xml; charset=utf-8; action="URL/SOME_FUNCTION"
Content-Length: 208
Authorization: Basic BASE64_STRING
任何人都可以确认这可能是问题吗?