I have created a couple of web services of type .asmx (.NET) getting data from a local MySQL database and displaying it as XML in the browser. This is already up and running.
I want to parse said XML and display it in an Android application I’m working on. As the MySQL database will only be updated a few times every month I don’t see the need to query the web service (and consequently the MySQL DB) every time I want to display the data in the Android application.
I figured it would make sense to download the XML returned by my web service and store it on the Android file system and parse it from there. Is this just incredibly backwards or is it doable?
When I access one of my local web service methods at
http://localhost/../WebService.asmx/GetLastDBUpdate
it returns a timestamp indicating when the database was last changed as XML in the browser, but I can’t figure out how to download the file raw XML file.
Can I do this, or should I do this differently?
Any suggestions are welcome.
One simple way to do the synchronization, is to pass the timestamp of the last update to the server. The server then either gives an empty response (no updates), or a list of objects that where updated since that timestamp. In both cases, it gives a new timestamp, so the client doesn’t have to stay in sync with the server.
Request
POST /WebService.asmx/GetUpdatesIf there is no previous update from that client, pass an empty timestamp, or leave it out. Set
UpdateNowtoFalse, to just see if there are any updates (<Objects>will always be empty).Response
OR
The
<Timestamp>could either be the time of the request, or the time of the latest update.Process: Parse the XML, and write it to an SQLite database. Save the timestamp for future updates.
To make the actual request to the web-service, you could use kSoap2 for Android: