如何使用HTTPS webservice和.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中缺少SOAP标头:47堆栈跟踪:#0 [内部功能]:SoapClient-> __ call(' teste',数组)#1 D:\ Inetpub \ wwwroot \ SOAP \ index.php(47):在D:\ Inetpub \ wwwroot \ SOAP \ index.php中抛出SoapClient-> teste(数组)#2 {main}第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;
答案 0 :(得分: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);
如果您遇到问题,请告诉我。