I have the following code to call the NTLM authetication for sharepoint data:
class NTLMSoapClient extends SoapClient {
/**
* Whether or not to validate ssl certificates
*
* @var boolean
*/
function __construct($location, $user, $passwd)
{
//print '1';
$headers = array(
'Method: POST',
'Connection: Keep-Alive',
'User-Agent: PHP-SOAP-CURL',
'Content-Type: text/xml; charset=utf-8',
'SOAPAction: ""',
);
$request='';
//$this->__last_request_headers = $headers;
$ch = curl_init($location);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER , $headers);
//print '2';
curl_setopt($ch, CURLOPT_POST , true );
curl_setopt($ch, CURLOPT_POSTFIELDS , $request);
curl_setopt($ch, CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_1);
// the next option may or may not cause issues with non-XML documents
//curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_NTLM);
curl_setopt($ch, CURLOPT_USERPWD, $user.':'.$passwd);
//print '3';
// optional SSL verification
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$response = curl_exec($ch);
print $response;
// TODO: Add some real error handling.
// If the response if false than there was an error and we should throw
// an exception.
if ($response === false) {
//print '5';
throw new EWS_Exception(
'Curl error: ' . curl_error($ch),
curl_errno($ch)
);
}
//print '6';
return $response;
}
}
The call is made as follows:
try{
$this->soapObject = new NTLMSoapClient( $this->wsdl, $this->spUser, $this->spPass);
}catch(SoapFault $fault){
//If we are unable to create a Soap Client display a Fatal error.
throw new Exception("Unable to locate WSDL file.");
}
The response is coming as wsdl. Why is the response coming as wsdl. It should return me the soap client object array as in normal soap client call. Any help is appreciated.
Thanks.