【问题标题】:SoapClient "Could not connect to host" exception with one WSDL API一个 WSDL API 的 SoapClient“无法连接到主机”异常
【发布时间】:2016-08-20 11:50:09
【问题描述】:

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

我与 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

【问题讨论】:

    标签: php web-services soap wsdl


    【解决方案1】:

    在与 WSDL 提供者协商,并检查双方的日志后,我们找到了 anwser。看起来 PHP 5.6 有一些问题,您必须将参数更改为 SOAP 1.2。这最终解决了这个问题。可以在第一条评论中找到解决方案: SOAP PHP fault parsing WSDL: failed to load external entity?

    // 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 );
    

    【讨论】:

    • 或者只是 $params = [ 'soap_version' => SOAP_1_2, 'stream_context' => stream_context_create(['ssl' => ['verify_peer'=>false]]) ] 对我来说...
    • 但最好的:将“openssl.cafile=C:/path/to/ssl/cacert.pem”添加到 php.ini !
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-06
    • 1970-01-01
    • 1970-01-01
    • 2017-04-14
    • 1970-01-01
    相关资源
    最近更新 更多