For as easy as SoapClient, I have never been successful. In almost every case, we turned off our own process, which always seemed better.
Example:
// set our headers to pass in cURL $headers = array( 'Content-type: text/xml;charset="utf-8"', 'Accept: text/xml', 'Cache-Control: no-cache', 'Pragma: no-cache', 'SOAPAction: ' . $action, 'Content-length: '.strlen($soap) ); // initiate cURL try { $_ch = curl_init(); curl_setopt($_ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($_ch, CURLOPT_URL, WEB_SERVICE_URL); curl_setopt($_ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($_ch, USERPWD, USER_ID . ":" . PASSWORD); curl_setopt($_ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); curl_setopt($_ch, CURLOPT_TIMEOUT, 10); curl_setopt($_ch, CURLOPT_POST, true); curl_setopt($_ch, CURLOPT_POSTFIELDS, $soap); curl_setopt($_ch, CURLOPT_HTTPHEADER, $headers); // process the request and get the result back $response = curl_exec($_ch); curl_close($_ch); return $response; } catch (Exception $e) { capDebug(__FILE__, __LINE__, "Error calling the web service: " . $e->getMessage(), "/tmp/errors.log"); return false; }
We had to massage the data later, but it always works!
source share