Saturday 15 January 2011

PHP Save XML from Soap response even if it fails with timeout -



PHP Save XML from Soap response even if it fails with timeout -

i save soap response xml file memory limit set 500m , timeout 900 fails many request error. according manual soap service recommend increasing memory , time limit avoid think 500m/900 pretty high already.

i saw script creating file , until point fails writes info file(which 52mb time) when request fails info in file overwritten error message.

is there way maintain info written out correctly file if request fails?

i save xml this:

<?php ini_set('memory_limit', '500m'); ini_set('max_execution_time','900'); ini_set('default_socket_timeout','900'); $pid='39'; $auth = 'abcd1234-efgh5678'; $client = new soapclient('http://www.example.com/services/service.asmx?wsdl', array("trace" => 1,"exceptions" => 0, 'features' => soap_single_element_arrays)); $result=$client->getstuff(array('pid'=>$pid, 'authcode'=>$auth)); $xmlsoap = $result->getstuffresult->any; $xml = simplexml_load_string($xmlsoap); $doc = new domdocument(); $doc->formatoutput = true; $doc->loadxml($xml->asxml()); $newxml = $doc->savexml(); $outputfilename = 'output'.date('ymd').'.xml'; $handle = fopen($outputfilename, "w"); fwrite($handle, $newxml); fclose($handle); echo 'ready'; //this echo here testing purposes ?>

php xml soap

No comments:

Post a Comment