• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps KSoap web service response

Hi everyone,

I've connected to a .net web service with KSoap2 and can display the response as a string fine, however I need to take that information and store it locally in an xml file.

Is this possible?

I was looking at saving the response information in a variety of variables, placing those in a JTable and then saving that out.

Any help or suggestions would be greatly received.

Thanks
 
As a follow up to this I managed to allocate out each value from the SOAP response into a number of STRING variables and then created another big STRING that contained all of the desired XML tags with the various variables appended inbetween so essentially it represents the XML content.

I saved this using the following code(FullDescription is the big string with everything in);
FileOutputStream fos = openFileOutput(
"testerfile.xml", Context.MODE_PRIVATE);

fos.write(
"".getBytes());

fos.write(
FullDescription.getBytes());

fos.close();

I can then view the contents of the file using the Toast method. However....even though I'm shown the content of the apparent file I can't actually find the file anywhere in my files that actually make up my app? If there's a file that exists and it shows me what's in it then surely I must be able to see the physical file?

Can anyone offer any input?
 
Wrap the the FileOutputStream in an OutputStreamWriter. In general in Java, use Reader and Writer when dealing with text. Use InputStream and OutputStream only when dealing with binary data.

Code:
Writer wtr
  = new OutputStreamWriter(
       openFileOutput("testerfile.xml", Context.MODE_PRIVATE),
       "UTF-8"
    );
wtr.write("<?xml version='1.0' encoding='UTF-8'?>\n");
wtr.write(FullDescription);
wtr.close();


In regards to where the file goes, you should find the file at the following path:

/data/data/app package/files/testerfile.xml

where app package is the package specified in your AndroidManifest.xml.
 
Back
Top Bottom