A simple question, yet I wasn’t able to find an answer in google.
How often is a web service class instanciated? Is it once per call to the web service, is it once per (arbitrary period of time), is it once per something else?
EDIT
I was hoping the class lives a good long live but seems like it does not.
The point is, I’ve got a resource which is used in serving requests, and loading this resource each time anew is not an option (on contrary, loading it once IS an option and is very good performace- and other-wise, and just simply ‘wise’). (No, nobody will get upset, the resource does not get blocked or something.)
So how do I have an object within a web service, single instance of which I can use to serve all requests?
Sorry if question has a too obvious answer like “use a static variable.” Being an experinced programmer, I still haven’t been properly introduced to web programming and still struggle with some general concepts.
So.
With all default settings, static variables of the web service class, as it would be in a regular desktop application, are only initialized once. This is true even if nobody calls the web service in a long time. You have to restart the app in IIS manager to have them re-initialized. Which is great and exactly what I wanted. So the answer is as simple as “use a static variable.”