无法使用带有ssl证书的bultin SoapClient类连接到SOAP服务器

时间:2019-03-06 21:18:40

标签: php soap soapui soap-client

我不确定自己在做什么错。我在SoapUI中使用了相同的wsdl文件和相同的证书,并且可以正常工作,但是当我切换到PHP时出现错误:

"__soap_fault": SoapFault {#1053 ▼
  #message: "Could not connect to host"
  #code: 0
  #file: "\app\Containers\Core\Services\Wrapper\SoapWrapper.php"
  #line: 71
  +"faultstring": "Could not connect to host"
  +"faultcode": "HTTP"
  trace: {▶}

这是我正在使用的代码:

$wsdl = "file.wsdl"
$options = [
        'location' => 'https://localhost:23443',
        'uri' => 'https://localhost:23443',
        "cache_wsdl" =>  0,
        "trace" => true,
        'exceptions' => 1,
        "local_cert" => file_get_contents(app_path() . "/Containers/Core/Services/Soap/Client/Resources/certificates/cert.p12")
    ],
public function setClient($wsdl, $options, array $headers = []) {
    $soapClient = new \SoapClient($wsdl, $options);
    if ($headers) {
        $soapClient->__setSoapHeaders($headers);
    }
    $this->client = $soapClient;
    return $this;

}

0 个答案:

没有答案