I am trying to use the MS Exchange 2007 Web Services from PHP and my first snag (of course) is successfully authenticating to the wsdl file when creating the SoapClient object.
I am able to fetch the WSDL file via curl simply by setting HTTPAUTH
and USERPWD
:
$exch = curl_init($exch_url);
curl_setopt($exch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($exch, CURLOPT_HTTPAUTH, CURLAUTH_NTLM);
curl_setopt($exch, CURLOPT_USERWD, $user.":".$pwd);
This was surprisingly easy. But I don't have the option of setting my authentication method in SoapClient (that I know of). I looked at nu_soap, but I don't like some of its core approach and I don't think I need a full library just to get one feature that I know I can get from the above code.
I found two different (almost identical) examples showing how to extend the SoapClient class for Exchange WS, but neither worked or made much sense. The main thing I picked up was that it was using the __dorequest
method to modify the Soap request before sending, but the documentation is on php.net is not very realistic or intuitive, so I'm not sure if this method will allow me to simply use curl to authenticate and get the WSDL.
Can anyone demonstrate a clear and simple way to either authenticate via curl first and use the headers for future SoapRequests (including the initial WSDL retrieval) or to extend the class so that it uses the above bit of code for the request?