SOAP:HTTPS客户端证书路径无效


SOAP: Invalid HTTPS client certificate path

当我运行下面给定的代码时,会生成错误ERROR: Invalid HTTPS client certificate path。我检查了certificate.pem和test.wsdl的路径是否正确。出现这种错误的原因可能是什么?

$wsdl = 'http://localhost:10088/test/test.wsdl';
$options = array(
    'local_cert' => 'http://localhost:10088/test/certificate.pem',
    'soap_version' => SOAP_1_1
);

try {
    $client = new Zend_Soap_Client($wsdl, $options);
    $result = $client->getLastResponse();
    print_r($result);
} catch (SoapFault $s) {
    die('ERROR: [' . $s->faultcode . '] ' . $s->faultstring);
} catch (Exception $e) {
    die('ERROR: ' . $e->getMessage());
}

选项local_cert的值必须是文件路径,而不是URL。将$options:的代码更改为

$options = array(
    'local_cert' => '/path_where_cert_is_stored/certificate.pem',
    'soap_version' => SOAP_1_1
);

由于Zend_Soap_Client的文档还不完整,您可以查看PHP:Soap-Manual了解更多信息,因为这是Zend_Soap_Client在后台使用的。在我看来,在PHP:SoapClient::SoapClient-Manual中可以更好地描述可能的参数(尤其是查看示例)。