使用一个WSDL API,SoapClient“无法连接到主机”异常

时间:2016-04-26 14:52:34

标签: php web-services soap wsdl

在移动到新的OVH VPS机器后,我遇到了与API的一个WSDL连接的问题,所以这可能是某种奇怪的错误配置。

我使用SoapClient的其他WSDL,工作正常,没有问题。我可以在地址上使用file_get_contents,但是当我使用SoapClient时,我尝试使用该API中的过程时会出现“无法连接到主机”的异常。

有什么想法吗?我尝试了一些带有SSL选项的stream_context。什么是最有趣的,另一个OVH VPS工作正常。

系统是Debian 8,板载PHP 5.6.19。

WSDL的地址在这里:https://api-test.paczkawruchu.pl/WebServicePwR/WebServicePwRTest.asmx?WSDL

1 个答案:

答案 0 :(得分:2)

在咨询WSDL提供商并检查双方的日志后,我们找到了anwser。看起来PHP 5.6有一些问题,你必须将参数更改为SOAP 1.2。这最终解决了这个问题。在第一条评论中可以找到解决方案: older

// options for ssl in php 5.6.5
$opts = array(
    'ssl' => array('ciphers'=>'RC4-SHA', 'verify_peer'=>false, 'verify_peer_name'=>false)
);
// SOAP 1.2 client
$params = array ('encoding' => 'UTF-8', 'verifypeer' => false, 'verifyhost' => false, 'soap_version' => SOAP_1_2, 'trace' => 1, 'exceptions' => 1, "connection_timeout" => 180, 'stream_context' => stream_context_create($opts) );
$oSoapClient = new SoapClient ( $url . "?WSDL", $params );
相关问题