Possible Duplicate:
ASMX Web Service slow first request
We are writing a full .NET/WPF/C# application using Microsoft's System.Web.Services.WebService class. We are seeing strange performance behaviours. I am no expert in the lower level workings of the class, so apologies if this is trivial.
The issue is the first webmethod call is very slow, and I'm not sure why or how to fix it. The performance test code does something like this:
ServiceSoapClient Svr = new ServiceSoapClient("ServiceSoap", url);
DateTime start = DateTime.Now;
bool connect = Svr.attemptConnection(true);
end = DateTime.Now;
Debug.WriteLine("server call: " + (end - start));
start = DateTime.Now;
connect = Svr.attemptConnection(true);
end = DateTime.Now;
Debug.WriteLine("server call 2: " + (end - start));
start = DateTime.Now;
connect = Svr.attemptConnection(true);
end = DateTime.Now;
Debug.WriteLine("server call 3: " + (end - start));
In this performance example, the first "server call" takes approximately 3 seconds! "server call 2", "server call 2", and any number after that take approximately 0.1 seconds. All "Svr.attemptConnection(true)" does is to take passed boolean and return it as is.
I am still doing research on this, but any help would be much appreciated. Why is the first call so slow and how can we change this?
Thx