Hi everyone
My intention is to enable NTLM authentification when using the native PHP SOAP client,
Most of the code is copied from an php.net manual example and it is said to be working.
I'm trying to override the __doRequest function in the SoapClient class and let it use cURL.
But I can't get the overriding part to work. __doRequest is never called, What am I doing wrong?
Any suggestions ?
class ExtSoapClient extends SoapClient {
private $proxy_login;
private $proxy_password;
...
public function __construct($wsdl, $options = array()) {
$this->proxy_login = $options['proxy_login'];
$this->proxy_password = $options['proxy_password'];
$this->proxy_host = $options['proxy_host'];
$this->proxy_port = $options['proxy_port'];
parent::__construct($wsdl, $options);
}
public function __doRequest($request, $location , $action , $version, $one_way = 0) {
return $this->cURL_call($location,$request);
}
protected function cURL_call($url, $data) {
$handle = curl_init();
curl_setopt($handle, CURLOPT_HEADER, false);
curl_setopt($handle, CURLOPT_URL, $url);
curl_setopt($handle, CURLOPT_FAILONERROR, true);
curl_setopt($handle, CURLOPT_HTTPHEADER, Array("PHP SOAP-NTLM Client") );
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_POSTFIELDS, $data);
curl_setopt($handle, CURLOPT_USERPWD ,'xxxxx:xxxxxxxx');
curl_setopt($handle, CURLOPT_HTTPAUTH, CURLAUTH_NTLM);
curl_setopt($handle, CURLOPT_PROXYUSERPWD, $this->proxy_password);
curl_setopt($handle, CURLOPT_PROXY, $this->proxy_host.':'.$this->proxy_port);
curl_setopt($handle, CURLOPT_PROXYAUTH, CURLAUTH_NTLM);
$response = curl_exec($handle);
if (empty($response)) {
throw new SoapFault('CURL error: '.curl_error($handle),curl_errno($handle));
}
curl_close($handle);
return $response;
}
}