简体   繁体   English

PHP的__dorequest方法用于SOAP的工作示例?

[英]Working example of PHP's __dorequest method for SOAP?

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. 我试图使用PHP的MS Exchange 2007 Web服务,并且在创建SoapClient对象时,我的第一个障碍(当然)已成功验证到wsdl文件。

I am able to fetch the WSDL file via curl simply by setting HTTPAUTH and USERPWD : 我只需设置HTTPAUTHUSERPWD即可通过curl来获取WSDL文件:

   $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). 但是我没有选择在SoapClient中设置身份验证方法(我知道)。 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. 我看了看nu_soap,但是我不喜欢它的某些核心方法,我不认为我需要一个完整的库来获得我知道可以从上述代码中获得的一个功能。

I found two different (almost identical) examples showing how to extend the SoapClient class for Exchange WS, but neither worked or made much sense. 我发现了两个不同的(几乎完全相同的)示例,它们显示了如何为Exchange WS扩展SoapClient类,但是都没有用或没有太大意义。 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. 我收到的主要内容是,它使用__dorequest方法在发送之前修改了Soap请求,但是php.net上的文档不是很现实或直观,因此我不确定此方法是否允许我只需使用curl进行身份验证并获取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? 谁能演示一种清晰简单的方法,要么首先通过curl进行身份验证,然后将标头用于将来的SoapRequest(包括初始WSDL检索),要么扩展该类,以便它使用上述代码进行请求?

SoapClient accepts SOAP_AUTHENTICATION_BASIC and SOAP_AUTHENTICATION_DIGEST as authentication mechanisms, NTLM authentication was already requested as you can see here . SoapClient接受SOAP_AUTHENTICATION_BASICSOAP_AUTHENTICATION_DIGEST作为身份验证机制, 已经请求了NTLM身份验证,如您在此处所见

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 . 在此之前,我从来不需要依赖NTLM auth方法,但经过一些Google搜索之后,我发现了一些有趣的文章, 但这似乎是使用PHP的SOAP进行NTLM身份验证的最终解决方案

I hope this solves your problem. 我希望这能解决您的问题。 =) =)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM