【问题标题】:PHP SOAP with HTTPS webservice and .PEM client certificate带有 HTTPS 网络服务和 .PEM 客户端证书的 PHP SOAP
【发布时间】:2012-12-07 07:59:05
【问题描述】:

如何使用 HTTPS 网络服务和 .PEM 客户端证书创建 PHP SOAP?

当我这样做时,我收到以下错误:

array(2) { [0]=> string(38) "testeResponse teste(teste $parameters)" [1]=> string(38) "testeResponse teste(teste $parameters)" }

致命错误:未捕获的 SoapFault 异常:[wsse:InvalidSecurity] D:\Inetpub\wwwroot\SOAP\index.php:47 中缺少 SOAP 标头 堆栈跟踪:#0 [内部函数]:SoapClient->__call('teste ', Array) #1 D:\Inetpub\wwwroot\SOAP\index.php(47): SoapClient->teste(Array) #2 {main} 在 D:\Inetpub\wwwroot\SOAP\index.php 中抛出在线47

代码:

$client = new SoapClient($wsdl, array(
    'local_cert'  => $localCert, 
     'passphrase' => $passphrase, 
     'style'      => SOAP_DOCUMENT, 
     'use'        => SOAP_LITERAL, 
     'exceptions' => true, 
     'trace'      => true)
);
$something = $client->teste(array());
echo $something->testeResult;

【问题讨论】:

    标签: php web-services soap certificate soapheader


    【解决方案1】:

    警告与 PEM 证书或 SSL 无关。很简单:

    缺少 SOAP 标头

    您找到SOAPHeader in the PHP manual。 PHP 手册中有一些使用示例和用户贡献的注释,本网站也有。例如:

    $auth = array(
        'UserName' => 'USERNAME',
        'Password' => 'PASSWORD',
        'SystemId' => array('_'=> 'DATA', 'Param' => 'PARAM'),
    );
    $header = new SoapHeader('NAMESPACE','Auth',$auth,false);
    $client->__setSoapHeaders($header);
    

    如果您遇到问题,请告诉我。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-01-10
      • 1970-01-01
      • 2017-04-01
      • 2013-10-18
      • 1970-01-01
      • 2018-02-02
      • 1970-01-01
      相关资源
      最近更新 更多