Sherwood
Sherwood

Reputation: 77

Getting SOAP data into php array

I am very new to SOAP and struggling with this!

I am calling for a SOAP response from an sql database

$client = new SoapClient("url......");
$soapquery = array('CoCode' => $cocode, 'WAPassword' => $webpass, 'strSQL' => $sqlt);
$soapresult = $client->SQL($soapquery);
$balance = $soapresult->SQLResult;
print_r($balance);

The result shows in Chrome as the value requested, but when inspecting the source it shows as an xml

<NewDataSet>
  <Table>
    <TOTAL>3348.1200</TOTAL>
  </Table>
</NewDataSet>

How can i get this information into either a PHP string or if i am calling more than one field into an array?

Thanks in advance.

Upvotes: 0

Views: 2288

Answers (1)

Anas
Anas

Reputation: 5727

I don't know why soapClient isn't parsing your response, but for a quick fix, you can use the php function simplexml_load_string.

Here is an example: How to parse SOAP response without SoapClient

Upvotes: 1

Related Questions