Search code examples
phpxmlsoapsavenusoap

PHP Soap - Save an xml server-side using nusoap


so I have a problem saving an XML file on my server in my Soap web service. I'm using nusoap and would like to load an existing xml file, edit some nodes and then save it. This function is stripped of most of the functionality, however it's still unable to save the file.

require_once 'nusoap/lib/nusoap.php';
function saveXML()
{
    $xml = simplexml_load_file('file.xml') or die(); //file is loaded successfully 
    $xml->asXml('newFile.xml'); // returns false (doesn't save the file)

    $dom = dom_import_simplexml($xml)->ownerDocument; 
    $dom->formatOutput = true;
    $dom->save('newFile.xml'); // returns false (doesn't save the file)
    return $dom->saveXML(); // after printing client-side I get the correct XML
}
$server = new soap_server();
$server->register('saveXML');
$server->service($HTTP_RAW_POST_DATA);
exit();

So I'm really clueless here. I've tried setting some write permissions on the folders and files in public_html but to no avail. Or is it actually impossible to write a file while executing a soap web service on the server-side?


Solution

  • I solved this by adding write permissions not just to the web service itself and the path where i wanted to save XML, but also to all the nusoap library files.