Hi, I need to use PHP's SoapClient with myfile-ca.crt. How can I tell SoapClient constructor to work with client certificate (crt file) ?
I am experienced with php SoapClient, but I never needed to work with secure soap client.
Thanks for any help
Hi, I need to use PHP's SoapClient with myfile-ca.crt. How can I tell SoapClient constructor to work with client certificate (crt file) ?
I am experienced with php SoapClient, but I never needed to work with secure soap client.
Thanks for any help
When constructing your SoapClient, you can pass in a configuration array as the second parameter. This array allows the options local_cert
. The local_cert option should point to the certificate file (in my experience the absolute path was needed to get it to work).
$wsdl = "service.wsdl";
$cert = "c:\secure_cert\webservice.pem";
$client = new SoapClient($wsdl, array('local_cert' => $local_cert);
See also the examples at the SoapClient manual page
Note: I've always been given .pem files; not sure if .crt is the same / works the same...?
After first problem with client certificate (which seems to be solved), I went to another error: After calling method $soapClient->GetXMLCatalogue(..) I am getting:
Could not connect to host
My code is:
$soapClient = new SoapClient('/......./service.wsdl',
array(
'local_cert'=> "/............/alltoys-ca.pem",
'style' => SOAP_DOCUMENT,
'use' => SOAP_LITERAL,
'exceptions' => true,
'trace' => true);
try {
$soapClient->GetXMLCatalogue(array('login' => 'xxx', 'password' => 'xxx'));
} catch (Exception $exp) {
die("Exp: " . var_export($exp, 1) . "\n"); // here I get error
}
I get following when dumping exception object:
...
'faultstring' => 'Could not connect to host',
'faultcode' => 'HTTP',
...
WSDL is publicly avilable at https://factorws.alltoys.cz:444/factorws.asmx?WSDL