tags:

views:

107

answers:

2

Hi guys,

I've got a SOAP fault response that i'm trying to output into a sort of 'print_r' nice format so I can include the fault in an email to our IT staff when SOAP request fails.

Can anyone tell me the best way to simply format an XML SOAP faultstring in the format, variableName: variableValue?

Cheers

A: 

You can try using simplexml_load_string() on the response and print_r() or var_dump() that.

Mike B
Thanks but this doesn't work, I just get 'object(SimpleXMLElement)#7 (0) { }'
The response/request is valid xml right? Make sure you're passing the right response property to simplexml_load_string();
Mike B
A: 

Well you should get the reply from the SOAP as an array (usually how I handled data in the past). I'm assuming here you mean failures in the soap calls, not connection failures.

Just iterate through the array's using the following:

foreach ($array as $key => $value)
{
    echo "<tr>";
    echo "<td>";
    echo $key;
    echo "</td>";

    echo "<td>";
    echo $value;
    echo "</td>";
    echo "</tr>";
}

And that would achieve the:

VariableName:  VariableValue

format

Jakub
Thanks but it really isn't this simple. Your suggested example caused a PHP error. This won't work with a SOAP __getLastRequest()