Fixed: Uncaught SoapFault exception: [HTTP] Error Fetching http headers using PHP SOAP

For me this error was caused by having logical errors in the PHP script that my SOAP service was calling.

$client = new SoapClient('http://www.example.com/index.php/api/soap/?wsdl', array('trace' => 1));
$client->__setCookie('XDEBUG_SESSION', 'PHPSTORM');

$session = $client->login('username', 'password');

try {
$result = $client->call(
$session,
'api.methodToCall',
array(
$param1,
$param2,
$someData,
)
);
echo "
<pre>";
print_r($result);
echo "</pre>
";
} catch (SoapFault $e) {
echo $e->getMessage()
}

$client->endSession($session);

To debug a SOAP service, pass the XDEBUG cookie by setting it to the SOAP request:
$client->__setCookie('XDEBUG_SESSION', 'PHPSTORM');
Don’t use the browser bookmarklet if you’ve got one of those.

Leave a Reply

Your email address will not be published. Required fields are marked *