How to use NTLM authentication with NuSOAP?

For a couple of weeks I’ve been implementing Webservices to feed resources on a SugarCRM project that I’m working on. As you may know SugarCRM provides NuSOAP, which is a SOAP Toolkit for PHP that brings some extra functionalities to SOAP implementation provided by PHP.

Today I had to use NTLM authentication method, unfortunately it isn’t supported by NuSOAP yet, but I’ve found that if you combine cURL with NuSOAP you can get through without a problem.

So here is the solution I came up with:

First of all I’ve upgraded NuSOAP to it’s latest version which is 0.7.3 (the one provided by SugarCRM didn’t supported cURL yet), then I wrote something similar to the code below.


$wsdl = 'http://project/file.php?wsdl';

$client = new nusoap_client($wsdl, true);
$client->setCredentials('', '', 'ntlm');
$client->setCurlOption(CURLOPT_USERPWD, 'auth_username:auth_password');

Facebook Twitter Linkedin Plusone