PHP Soap - Save an xml server-side using nusoap

760

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?

173

Answer

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.

People are also looking for solutions to the problem: php - Dynamic Select Dropdown Wordpress By advanced custom field

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.