I am making synchronous web service calls in my application, there are scenario where user requires to stop the execution of web service call in between i.e before response is returned .
Does any one has an idea how to stop a web service call in middle.
Thnaks in advance
Your biggest problem will be matching the HTTP request (SOAP also?) to stop with the SOAP request that is running since SOAP does not normally maintain any sort of session ID for you.
On the client side you could close the connection and hope for the best.
Exactly what do you have on the client side? you should certainly be running the SOAP request in its own Thread if you want the client to be able to respond at all.
I am using SOAp for web service call.
Now the requirement is if web service call is taking a long time , then i need to give user a facility to stop the webservice call.
So how can i cut a call , before response is returned.
Is there a way to implemnt this scenario
Make WS call in a separate thread and along with that start a parallel timer thread. Mention the time in the timer thread (using sleep or join methods). If you do not get the response in time, then stop the WS invoker thread and pop a message to the user.
Note : If user still says I am OK to wait for the response, above solution has to be tweaked. This solution will stop the WS invoker thread alltogether and the response would always be ignored.
Waswani Naresh wrote:Asynchronous call generally denotes background processing and letting the foreground flow continue. Is that the intention here ? Not very sure if this would be the solution.
Asynchronous client, not server.
Make WS call in a separate thread and along with that start a parallel timer thread.
This is exactly what I meant when suggesting an asynchronous client. The advantage is that you do not have to start a thread yourself. When generating client artifacts using wsimport, you need to supply a binding file in which you set <enableAsyncMapping>true</enableAsyncMapping>, in order to get asynchronous client methods.
so suggest something in context with sysnchronous WS,
i have thought , when we make a wS call a thread is created between java and server(where services lie) , if i can get hold of that thread then i can truncate it .
I checked on response object in eclipse ide , i was getting prompted for only to 2 threading methods notify and wait (sort of confirming my doubt that we dont have the access to truncate ws call once started)
William Brogden wrote:On the service side, you could have the service throw a SOAP exception and hope that the toolkit unwinds all the resources properly.
With the Restlet framework the Resource class has the allowPost method, which can return false. At that point, no new HTTP post requests will not be processed until allowPost returns true.