【问题标题】:PHP Soap issue: OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 54 or SSL: Connection reset by peerPHP Soap 问题:OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 54 or SSL: Connection reset by peer
【发布时间】:2020-07-29 21:22:27
【问题描述】:

我尝试执行 SOAP 请求,

  1. 请求在 Soap UI 上运行良好,给出了正确的响应,- 从下面的尝试中复制粘贴有效负载
  2. request not work on Postman 给出 Could not get any response 错误
  3. 使用 php SoapClient 库发出 SoapClient::__doRequest(): SSL: Connection reset by peer 错误的请求不起作用
  4. request not work using php curl 给出 OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 54 错误

所有准备好在无 wsdl 模式下尝试 SoapClient,并使用不同的 ssl 验证选项,并在远程服务器上尝试,因此不是互联网连接问题。

这是第 3 点的代码:

$this->client = new \SoapClient($this->wsdl, [
            'soap_version' => SOAP_1_1,
            'exceptions' => true,
            'trace' => true,
            'cache_wsdl' => WSDL_CACHE_NONE,
        ]);

$response = $this->client->__doRequest(trim($xml), $url, 'getReport', SOAP_1_1);

这是第 4 点的代码:

 $ch = curl_init();
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1); // both 0 & 1 not works
        curl_setopt($ch, CURLOPT_URL, $location);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); // also tries different values
        curl_setopt($ch, CURLOPT_TIMEOUT, 15); // here too
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, trim($request));

        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_VERBOSE, 1);

        curl_setopt($ch, CURLOPT_HEADER, 1); // also not works without this
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); // and this

        $response = curl_exec($ch);

我能做些什么来更深入地调试这个问题并解决它?

【问题讨论】:

  • 你控制服务器吗?你能看看它的日志文件吗?否则,您是否尝试将另一个客户端连接到同一服务器,例如openssl s_client?或者在命令行上curl
  • 无权访问服务器日志已经在 curl 和 soapclient 上尝试过,但没有成功,想知道为什么 SoapUi 有效

标签: php ssl curl soap wsdl


【解决方案1】:

原来标题值SOAPAction 需要在额外的转义引号中,如下所示:

$headers = [
   "SOAPAction: \"http://example-url.com\"",
]

【讨论】:

    猜你喜欢
    • 2022-12-06
    • 2019-11-04
    • 2021-03-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-02
    • 2016-06-21
    相关资源
    最近更新 更多