Today I’ve searched some time to a specific case we have for calling an (external) ASP.NET web service with the following requirements:
- Calls must be done asynchronous
- A timeout must implemented, because web service can take long time to execute
On the internet and StackOverflow many questions appear on this subject, but are either dated or are suggesting using the WebRequest.TimeOut property which is only applicable for synchronous calls.
One alternative is using an System.Threading.Timer. Starting the timer just before starting the call and cancelling it when it reaches the TimerCallback.
However, I think there should be a more common approach to such cases. Unfortunately couldn’t find it so far. Anyone has an idea for setting client side timeouts on async web service calls?
Thanks in advance.
Please check your app.config it will have some settings for servicemodel and it has various values that can be configured.
When I added new Service Reference, I can see following things in my app.config,
Try removing and adding reference again, make sure your app’s target framework is 4.0 and you are adding Service Reference (Not the Web Reference).