DanielGibbs DanielGibbs - 2 years ago 155
PHP Question

How to troubleshoot PHP-EWS/SOAP error?

last year I made a PHP project that interacted with and Exchange 2010 Server using Exchange Web Services. I have just come back to this project, and when I try to use any of the php-ews methods, I get this error:

SoapClient::__doRequest() returned non string value

I don't exactly understand how all the SOAP and CURL code works, so could anyone give me a few pointers in how to go about troubleshooting this?

Things I have tried

When I go to the URL that the SOAP request is being sent to in a web browser, I am warned that it doesn't have an valid certificate, so I have put the following code in both my NTLMSoapClient and NTLMStream:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);

But I still receive the same error.

When I browse to the address in a web browser and ignore the certificate warning, I am prompted for a password, and it only seems to accept the admin password, and then It redirects me to services.wsdl.

Changing the username and password in my code to the admin ones doesn't make any difference.

Answer Source

I used to work on a similar project, but involving PHP and MS Sharepoint web services. I used NuSoap library to facilitate working with SOAP.

I have no experience with PHP EWS, but I'd recommend you to look into request and response codes, data and headers to see what exactly you send and receive. This info will probably help you find your problem (is it either authentication error or failure to get wsdl description or invalid arguments for the web method etc.).

// For debugging purposes
// return transfer data as a result
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// read headers
curl_setopt($ch, CURLOPT_HEADER, 1);
// show request headers, will display all the outgoing info, including fields
curl_setopt($ch, CURLINFO_HEADER_OUT, true);

// Make the request
$data = curl_exec($ch);
$errors = curl_error($ch);
// get info about the transfer, for debugging purposes
$details = curl_getinfo($ch); 


// Displaying debugging info

For more details on my experience see my posts about authorizing and calling MS SPS web service from PHP using CURL and NuSoap.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download