Reputation: 93
I got a SOAP (normal php client) Result from my request I want to save the result as a XML file ? But how ?
$result = $client->__soapCall('MYwebServices',array($params));
$xml = simplexml_load_string($result);
$fp = fopen("out.xml","w");
fwrite($fp,$xml);
fclose($fp);
Upvotes: 1
Views: 4958
Reputation: 51950
If you want to get the XML returned by the web service, you should use SoapClient::__getLastResponse()
(along with the trace
option).
$client = new SoapClient(..., array('trace' => 1));
// Do your __soapCall here
$xml = $client->__getLastResponse();
// Work with the XML string here
Upvotes: 4
Reputation: 5905
Does the code above not do it, if not try:
$result = $client->__soapCall('MYwebServices',array($params));
$xml = new DOMDocument();
$xml->load($result);
$xml->save("out.xml");
This might be broken if the return is not xml or the xml is improperly formatted, in which case try this:
$result = $client->__soapCall('MYwebServices',array($params));
libxml_use_internal_errors(true);//load if improperly formatted
$xml = new DOMDocument();
if ($xml->load($result))
{
$xml->save("out.xml");
}
else {
echo "The return data was not xml";
}
Upvotes: 0