jaybo Posted November 6, 2021 Share Posted November 6, 2021 I am sending a SOAP request and the response is 200 ok but I am struggling to output the $response. This is the website for the request Calculator Web Service and also the xml file document tree http://dneonline.com/calculator.asmx?wsdl Here is my php code; <?php $xml = '<?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <Add xmlns="http://tempuri.org/"> <intA>1</intA> <intB>2</intB> </Add> </soap:Body> </soap:Envelope>'; $url = "http://dneonline.com/calculator.asmx?wsdl"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); $headers = array(); array_push($headers, "Content-Type: text/xml; charset=utf-8"); array_push($headers, "Accept: text/xml"); array_push($headers, "Cache-Control: no-cache"); array_push($headers, "Pragma: no-cache"); array_push($headers, "SOAPAction: http://tempuri.org/Add"); if($xml != null) { curl_setopt($ch, CURLOPT_POSTFIELDS, "$xml"); array_push($headers, "Content-Length: " . strlen($xml)); } // curl_setopt($ch, CURLOPT_USERPWD, "user_name:password"); /* If required */ curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $response = curl_exec($ch); $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); echo "<pre>"; print_r($response->AddResponse); echo "</pre>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/314177-soap-request-in-php-with-curl/ Share on other sites More sharing options...
requinix Posted November 6, 2021 Share Posted November 6, 2021 Three problems. First is finding out exactly what $response contains. Try to print_r or var_dump it directly without any ->AddResponse or other changes. You'll discover that the response isn't what you think it is. Second is that $response is a string, not an object. Third, and arguably most important, is that you're implementing SOAP on your own instead of using PHP's existing SOAP functionality. Quote Link to comment https://forums.phpfreaks.com/topic/314177-soap-request-in-php-with-curl/#findComment-1591827 Share on other sites More sharing options...
jaybo Posted November 8, 2021 Author Share Posted November 8, 2021 I am seeing that $response returns bool(false). I have been trying to use SoapClient but continuously get the error: Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'https...' I have looked in the php.ini file to address any exceptions and don't appear to get any success if I make adjustments there. This is the first time I have used SOAP and while it appears straight forward to me, I have some stumbling blocks to try to work though. As I have some experience of using cURL I have taken this route due to the resistance I am experiencing with SoapClient. Quote Link to comment https://forums.phpfreaks.com/topic/314177-soap-request-in-php-with-curl/#findComment-1591853 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.