Jump to content

Curl Soap Response Parsing Issue


Go to solution Solved by AeroProDrive,

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/311594-curl-soap-response-parsing-issue/
Share on other sites

  • Solution

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.