I am trying to access a WCF service using the PHP soap client. I keep receiving the error: "Error Fetching http headers" I tried increasing the default_socket_time as well. I need to use basic authentication as well as parameters for the methods when accessing the services. Following is my PHP code. I am unable to change the server configurations.
<?php
$wsdl = "https://example.com/NewServer/Services/WCFServices.svc?wsdl";
$url=$wsdl;
$svc = 'WCFServices';
$func = 'getValId';
$username = "admin";
$password = "admin";
$apiauth =array('UserName'=>$username,'Password'=>$password);
$authHeader = new SoapHeader('https://tempuri.org/', 'AuthHeader', $apiauth);
$client = new SoapClient($url, array('soap_version' => SOAP_1_2,
'exceptions' => true,
'trace' => true);
try
{
ini_set('default_socket_timeout', 600);
$client->__setSoapHeaders($authHeader);
$info = $client->__soapCall($func, array('extRef' => 'ABCD'));
var_dump($info);
}
catch (SoapFault $fault)
{
var_dump($fault);
$xml=$fault->faultstring;
die;
}
?>
Guidance into correct path would be appreciated.
The WCF service which I was invoking had both HTTP and basic bindings available. So I invoked the basic endpoint which uses SOAP 1.1 version. Posting the code as it will be useful to someone in the future.