PHP SoapClient - > __call()返回'无法连接到主机'

时间:2018-03-15 14:44:58

标签: php soap ubuntu-18.04

我最近将我的开发环境从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 ()$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

有人可以确认这可能是问题吗?

0 个答案:

没有答案