0

I'm trying to make my mind up in what's the most efficient way to approach my problem with webservices.

My situation: I'm developping an Android app which is storing and retrieving data from a mysql database (on my own server-pc) trough webservices. The webservice executes an sql command and either makes an xml file or stores the data in the database after the user pressed the submit button.

The next case is my problem:

The webservice has to be poked before it will creates the xml. Till now i have to go to the webservice in the browser (xxx.xxx.x.xxx:xxx/webservice.php), and then it will update an xml file ((xxx.xxx.x.xxx:xxx/webserviceList.xml). Ofcourse this has to go automatically.

So if an user sends data to the database (for example: he added a customer), the webservice should update the xml file (so xxx.xxx.x.xxx:xxx/webservice.php has to be entered)

Now i think there are 2 ways to fix this (correct me if there are more ways)

  • somehow let the database poke the webservice
  • let the app poke the webservice

If there is a way to let the database poke the webservice, that would be the most efficient i guess?? Because my goal is ofcourse to make the app as fast as possible

Otherwise, is there a simple way to let the app touch/poke the website/webservice without sending and receiving data, with the only goal to update the xml created by the webservice?

I hope you guys can give me some advice:)

Thanks in advance!

GeertG
  • 158
  • 2
  • 12
  • That's sending data to the database, i already got that working. All i need to do is touch the webservice so it updates a xml file – GeertG Oct 03 '13 at 07:20

2 Answers2

1

You need to write REST API's to achieve this. Once you have written an API in your backend, you can call it from any HTTP client. This client can be your android app or another server (the server that hosts your db).

It's generally good practice to offload as much logic as possible to servers rather than the mobile apps. So I would suggest that once data is sent from the app to your db, you call the api to update data on your main server from the server hosting your db.

Community
  • 1
  • 1
Anup Cowkur
  • 20,443
  • 6
  • 51
  • 84
  • I actually already have an method that calls Http functions to get the xml files from the web. So you would say: call the class with the AsyncTask that recieves the xml again after it recieved the xml, but then pass another URL and do nothing with the data? – GeertG Oct 03 '13 at 06:51
  • you need to have to have separate API's for separate things. So make another call to a "update" API whose only job is to tell the server to update itself whenever this action needs to be taken. Small modular API's that do one thing only is better than one single API that'll handle the whole flow. But this depends on your architecture and other requirements. – Anup Cowkur Oct 03 '13 at 07:04
0

Make sure that you write the REST api services and use the Observer Design Pattern

Mothy
  • 406
  • 1
  • 7
  • 19