AeroProDrive Posted October 13, 2020 Share Posted October 13, 2020 Hello guys, What I do is consuming SOAP Web Service that returns XML data as follows: <?xml version="1.0" encoding="utf-8"?> <string xmlns="http://tempuri.org/">false</string> Unfortunately the curl returns something that I can't parse to XML and get the value "false" My PHP code is the following: $soap_do = curl_init(); curl_setopt($soap_do, CURLOPT_URL, $url ); curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true ); curl_setopt($soap_do, CURLOPT_POST, true ); curl_setopt($soap_do, CURLOPT_POSTFIELDS, $soap_request); curl_setopt($soap_do, CURLOPT_HTTPHEADER, $header); curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false); $result = curl_exec($soap_do); $xml = simplexml_load_string($result); return $xml; How do I parse this SOAP response? Thank you very much Quote Link to comment https://forums.phpfreaks.com/topic/311594-curl-soap-response-parsing-issue/ Share on other sites More sharing options...
gw1500se Posted October 13, 2020 Share Posted October 13, 2020 That result is parsable but I suspect that is not really your question. Are you asking why it is returning false? If so that is a function of the SOAP request not a parsing issue. You need to clarify what you are doing/asking. Quote Link to comment https://forums.phpfreaks.com/topic/311594-curl-soap-response-parsing-issue/#findComment-1581854 Share on other sites More sharing options...
Solution AeroProDrive Posted October 13, 2020 Author Solution Share Posted October 13, 2020 I think I found the problem. The @result is of bool type while I was expecting the string from the xml Therefore I changed return $result; to return $result === true ? "true" : "false"; Now it works like a charm Thank you so much Quote Link to comment https://forums.phpfreaks.com/topic/311594-curl-soap-response-parsing-issue/#findComment-1581855 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.