0

I want to ask about webservices.

Consider a scenario :

I entry my data in a vfp desktop apps. When I hit 'save', the apps saved my data in local database, and send it as xml to a webservice ( a php file ) in remote location. The web service then insert my data to a vfp database in the remote location. For example, as soon as I hit 'save', I realize that I've made a mistake. I change my entry and hit 'save' once again. The data will send again via webservice to update the data in the remote location.

The question is :

How do I guarantee that the second update will be inserted in the remote location after the first insert? I mean does the sequence of the operation will guarantee the same sequence of operation in the web server?

Many thanks.

wong chung yie
  • 175
  • 1
  • 4
  • 14

1 Answers1

0

It will generally not be the same sequence because the two requests are isloated from each other and the time to reach the destination depends on the route taken. In most cases it will work as expected though.

You can have your client wait with updates until the previous update is done. Simply check the response from the remote location.

There is not much you can do on the remote location's end because even if you could detect the missing update request, you don't have it and it may never come. There are two ways to detect missing requests: Either give each request an ongoing number, or add some kind of version to the update.

For the first way, if a request arrives, check if it has the number previousNumber + 1. If not, either report an error or delay it until request previousNumber + 1 arrives.

For the second way check if the current version of the remote data is the same as the expected version in the request. If not, report an error.

This version could be the time you clicked your "save"-button. If the second update arrives before the first, the first update will have a smaller timestamp than the current timestamp used by the second request.

Basti
  • 3,998
  • 1
  • 18
  • 21
  • Thank you for the reply. It's confirming my thought. I end up creating a variable that indicate a 'free to send' status. It's values changes by the send action and the response from the remote location. So the next data won't be send unless i know the previous data has transfered, or has failed and need to be retransfered. – wong chung yie Apr 13 '12 at 08:41