943,202 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 226
  • PHP RSS
Sep 2nd, 2010
0

Can't override the __doRequest function from the SoapClient class

Expand Post »
Hi everyone

My intention is to enable NTLM authentification when using the native PHP SOAP client,
Most of the code is copied from an php.net manual example and it is said to be working.

I'm trying to override the __doRequest function in the SoapClient class and let it use cURL.
But I can't get the overriding part to work. __doRequest is never called, What am I doing wrong?

Any suggestions ?


PHP Syntax (Toggle Plain Text)
  1. class ExtSoapClient extends SoapClient {
  2.  
  3. private $proxy_login;
  4. private $proxy_password;
  5. ...
  6.  
  7. public function __construct($wsdl, $options = array()) {
  8.  
  9. $this->proxy_login = $options['proxy_login'];
  10. $this->proxy_password = $options['proxy_password'];
  11. $this->proxy_host = $options['proxy_host'];
  12. $this->proxy_port = $options['proxy_port'];
  13. parent::__construct($wsdl, $options);
  14. }
  15.  
  16. public function __doRequest($request, $location , $action , $version, $one_way = 0) {
  17. return $this->cURL_call($location,$request);
  18. }
  19.  
  20. protected function cURL_call($url, $data) {
  21.  
  22. $handle = curl_init();
  23. curl_setopt($handle, CURLOPT_HEADER, false);
  24. curl_setopt($handle, CURLOPT_URL, $url);
  25. curl_setopt($handle, CURLOPT_FAILONERROR, true);
  26. curl_setopt($handle, CURLOPT_HTTPHEADER, Array("PHP SOAP-NTLM Client") );
  27. curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
  28. curl_setopt($handle, CURLOPT_POSTFIELDS, $data);
  29. curl_setopt($handle, CURLOPT_USERPWD ,'xxxxx:xxxxxxxx');
  30. curl_setopt($handle, CURLOPT_HTTPAUTH, CURLAUTH_NTLM);
  31. curl_setopt($handle, CURLOPT_PROXYUSERPWD, $this->proxy_password);
  32. curl_setopt($handle, CURLOPT_PROXY, $this->proxy_host.':'.$this->proxy_port);
  33. curl_setopt($handle, CURLOPT_PROXYAUTH, CURLAUTH_NTLM);
  34. $response = curl_exec($handle);
  35. if (empty($response)) {
  36. throw new SoapFault('CURL error: '.curl_error($handle),curl_errno($handle));
  37. }
  38. curl_close($handle);
  39. return $response;
  40. }
  41.  
  42. }
Last edited by zeuz; Sep 2nd, 2010 at 4:31 am.
Reputation Points: 10
Solved Threads: 2
Newbie Poster
zeuz is offline Offline
4 posts
since Jan 2010

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: How to stop sending data on refresh
Next Thread in PHP Forum Timeline: mailto function





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC