views:

85

answers:

2

Hi,

I have a web page (.aspx) that calls a third party web service to get some data. It usually takes couple of seconds to get the response back, and then the rest of the page will load. Occasionally the call gets stuck either due to the web service is down, or internet connection, etc., the page just hang there and will not load.

My questions is:

1) Is there a way to abort/cancel the web service call after a set amount of time?

2) Is it even possible to verify the status of the web service before calling it?

Thanks.

+4  A: 

This question will point you in the right direction. It talks about how to set a default timeout for the web service, so it will automatically cancel if it takes too long.

http://stackoverflow.com/questions/536629/timeout-for-asynchronous-web-service-call-in-c

The only way to verify the status of a service is by calling it. You can tell if it down by the response you get. (500 404 etc.).

Here is the difference between the two and what Microsoft recommends.

http://msdn.microsoft.com/en-us/library/ms998562.aspx#scalenetchapt10_topic14

Kevin
Thanks for the quick reply.Could you explain what's the difference between setting executionTimeout in the config file and setting the timeout property for the proxy? Are those two the same, does one value over-writes another? Thanks!
drizzle
A: 

There are multiple ways to handle this kind of problem. One of the biggest hangups of moving to a web app from non web-based applications is the responsiveness of the UI. If you want your interface to be more responsive to the user, you might want to think about using AJAX for async results. When the page loads, the section that is requiring a 3rd party web service can display some kind of loading indication (while everything else displays instantly), and then through RPC the content appears when it finished loading (or if a certain amount of time passed, displays a timeout error).

NebuSoft