1

How to create PHP SOAP with HTTPS webservice and .PEM client certificate ?

When i did that i received the follow errors:

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

Fatal error: Uncaught SoapFault exception: [wsse:InvalidSecurity] SOAP header missing in D:\Inetpub\wwwroot\SOAP\index.php:47 Stack trace: #0 [internal function]: SoapClient->__call('teste', Array) #1 D:\Inetpub\wwwroot\SOAP\index.php(47): SoapClient->teste(Array) #2 {main} thrown in D:\Inetpub\wwwroot\SOAP\index.php on line 47

The code:

$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;
Community
  • 1
  • 1

1 Answers1

1

The warning is not about the PEM certificate or SSL. It is simply:

SOAP header missing

You find SOAPHeader in the PHP manual. There are some usage examples and user contributed notes in the PHP manual and also here on this website, too. For example:

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

Let me know if you run into problems.

hakre
  • 193,403
  • 52
  • 435
  • 836