views:

4698

answers:

4

Hello everyone,

I am using C# and created a proxy from a ASP.Net asmx Web Service at client side, by using Add Web Reference... feature of VSTS 2008.

And I am using the asynchronous method call model (i.e. call the AsyncXXX method, which will return immediately) and handles the complete event (I add event handler to handle the complete even when the reponse is received from server side).

I find if there is no response from server for a long time, the complete event will not be fired.

My questions are,

  1. Is it expected feature or my bug that if no response from server after call AsyncXXX method, complete event handler will not be called?

  2. Are there any way to assign timeout value -- so that I do not wait on the complete event handler infinitely?

thanks in advance, George

A: 

SoapHttpClientProtocol which your proxy should inherit from has a Timeout property inherited from its ancestor WebClientProtocol. It could answer your second question.

Tyalis
I tried but it seems only works for synchronous interface.
George2
+1  A: 

In the web.config for your webservice you can set a timeout (You will also need to change to not be in debug mode if it is). This should then cause it to throw an exception that will raise your completed event. You will then need to inspect for an exception to see if it passed or failed.

ck
Thanks ck, which exact config item in web.config do you mean?
George2
<system.web><httpRuntime executionTimeout="120" /></system.web>See http://msdn.microsoft.com/en-us/library/e1f13641.aspx
ck
A: 

If you want your web service to never timeout you can put this line in the web services class:

this.Timeout = System.Threading.Timeout.Infinite;

Kelly
A: 

I tried to use the:

this.Timeout = System.Threading.Timeout.Infinite;

but my C# web service won't compile.

public class Service1 : System.Web.Services.WebService
{

I placed the line in the constructor for the above class...

Where are you supposed to put it?