Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to build a time consuming web service

a simple and theoric question, the answer is probably one, but I would like to listen to some opinions and suggestions. I am in need of realizing a web services (in java) that will launch a time consuming process, which is going to parse some input file and do dome db staff.

What are the best approach to let the user knows that the whole process not only started, but came to an end, with parsing, updating db... ? Because I cannot hang the user waiting for the whole process to finish.

Note: the user is authenticated before starting the process.

EDIT: the web service is accessed not only via web browser, but clients can access it with any client built with the language they want, as long as they refer to the wsdl.

thanks

like image 369
Leonardo Avatar asked Dec 29 '22 06:12

Leonardo


1 Answers

For your scenario, You should implement asynchronous web services. With asynchronous web services, you have two options.

  1. (as someone already mentioned) you can do polling of the service to see if the process is done
  2. You can ask the server to callback

The first approach is easy to implement and it would work with many WS- libraries. However this comes with a drawback of your server having to waste bandwidth for client's polling requests. After all, it's polling. and most of the times, polling is a bad idea.

The latter one wouldn't be as straightforward as the former one to implement. And you I don't know if every JAX-WS library would support it. To support you, i did a quick google search and found this link.

http://www.developer.com/java/web/article.php/3863416/Using-Axis2-and-Java-for-Asynchronous-Web-Service-Invocation-on-the-Client-Side.htm

That might help you a little.

like image 114
Roshan Amadoru Avatar answered Jan 13 '23 01:01

Roshan Amadoru