0

我有以下代码来调用 Sharepoint 数据的 NTLM 身份验证:

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;
    }
}

调用如下:

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.");
        }

响应以 wsdl 的形式出现。为什么响应以 wsdl 的形式出现。它应该像普通的soap客户端调用一样返回soap客户端对象数组。

4

0 回答 0