Good day.
I want to integrate with a WCF web service with Message Security from PHP. The web service expect a certificate from the client (the PHP code) and does not require any usernames or passwords. It also uses wsHttpBinding. I have a Windows x64 pc with IIS7 running on it and I am able to execute php code from my browser.
I have tried to use the SoapClient() in PHP with the following code:
<?php
ini_set("soap.wsdl_cache_enabled", "0");
try
{
$context = stream_context_create(["ssl" => ["local_cert" => "./cert/TestClient.pem", "CN_Name => CN=TestClient"]]);
$options = ["soap_version" => SOAP_1_2, "authentication" => SOAP_AUTHENTICATION_DIGEST, "context" => $context];
$service = new SoapClient("http://vanzyld:49321/pointerws/?wsdl", $options);
$service->GetVehicleList([3538]);
}
catch (SOAPFault $f)
{
error_log('ERROR => '.$f);
}
?>
but,
With SOAP_1_2, this is the error that is returned from the call:
ERROR => SoapFault exception: [HTTP] Error Fetching http headers in C:\inetpub\phproot\WebService\GetVehicles.php:16
Stack trace:
#0 [internal function]: SoapClient->__doRequest('<?xml version="...', 'http://vanzyld:...', 'http://pointers...', 2, 0)
#1 C:\inetpub\phproot\WebService\GetVehicles.php(16): SoapClient->__call('GetVehicleList', Array)
#2 {main}
And with SOAP_1_1, this one is returned.
ERROR => SoapFault exception: [HTTP] Cannot process the message because the content type 'text/xml; charset=utf-8' was not the expected type 'application/soap+xml; charset=utf-8'. in C:\inetpub\phproot\WebService\GetVehicles.php:16
Stack trace:
#0 [internal function]: SoapClient->__doRequest('<?xml version="...', 'http://vanzyld:...', 'http://pointers...', 1, 0)
#1 C:\inetpub\phproot\WebService\GetVehicles.php(16): SoapClient->__call('GetVehicleList', Array)
#2 {main}
After much research, it looks like the SoapClient does not handle calls to a WCF web service that implements Message Security, that well. One of the suggestions were (from here: How to communicate between PHP and WCF securely) that I install a 3rd party package from WSO2, but this also seems not to be the best route to follow, as WSO2 does not support this anymore. I also could not get the WSF installation working on my PC, even after following all the steps on how to install wsf on my PC. (https://wso2.com/project/wsf/php/2.0.0/docs/install_guide.html - I followed steps 2.1 and 2.4) The WSF section never popped up on my phpinfo page as being enabled. The PHP error that was returned after installing WSF, was simply that the code could not find the WSClient() class.
Is there any other PHP class or library or third party object that can be used to successfully integrate PHP code with a WCF web service that uses Message Security? Or is there a way for the SoapClient() to actually work with this kind of WCF service? Or is PHP just limited with regards its ability to integration with a Message Security WCF web service?
Thank you. Daleen