开发者

Working example of PHP's __dorequest method for SOAP?

开发者 https://www.devze.com 2022-12-18 08:20 出处:网络
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 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 So开发者_运维问答ap 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?


SoapClient accepts SOAP_AUTHENTICATION_BASIC and SOAP_AUTHENTICATION_DIGEST as authentication mechanisms, NTLM authentication was already requested as you can see here.

I've never needed to rely on the NTLM auth method before but after some Googling I've found some interesting articles but this seems to be the ultimate solution for NTLM authentication with PHP's SOAP.

I hope this solves your problem. =)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号