473,388 Members | 1,427 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Can I start a web service before anyone connects?

I am new to web services, and wonder if it is possible to have a web
service run all time and start the constructor before anyone calls any
web method. My problem is that a lot of data is read in the
constructor, and if this is to be loaded every time somebody calls a
web method, thing are really slow. I have tried to just call the web
methods, but it seems like the constructor is called every time.

May 5 '06 #1
4 1274
All you can do is make an app which will call a method (or methods) on the
web service after the service has restarted (or browse to it in IE).
Unfortunately until the first call is made the web app is not loaded and as
you say it is a bit slow the first time. Once it is loaded it will stay
loaded so performance should improve.

Will
<ma*************@gmail.com> wrote in message
news:11**********************@e56g2000cwe.googlegr oups.com...
I am new to web services, and wonder if it is possible to have a web
service run all time and start the constructor before anyone calls any
web method. My problem is that a lot of data is read in the
constructor, and if this is to be loaded every time somebody calls a
web method, thing are really slow. I have tried to just call the web
methods, but it seems like the constructor is called every time.

May 5 '06 #2
If you don't need to load the data every time - why not store the data
using statics?

You could even use the cache and inside your constructor, check to see
if the cache is empty. If it is, populate it, if it isn't use it.

Josh
http://www.thejoyofcode.com/

May 5 '06 #3
A new instance of the class is created for each request .. this helps remove
threading problems you may run into as your class does not need to be
re-entrant.

To work around this either move your initialization to another class
(singleton pattern would work very well for this) or move them into static
variable within the class so they are shared between all instances.

Cheers,

Greg Young
MVP - Visual C#

<ma*************@gmail.com> wrote in message
news:11**********************@e56g2000cwe.googlegr oups.com...
I am new to web services, and wonder if it is possible to have a web
service run all time and start the constructor before anyone calls any
web method. My problem is that a lot of data is read in the
constructor, and if this is to be loaded every time somebody calls a
web method, thing are really slow. I have tried to just call the web
methods, but it seems like the constructor is called every time.

May 5 '06 #4
Create a method, for instance InitData, which delivers as array or structure
all necessary data to run the all web service methods.
Instruct the users to write this code in Web Applications

sttruct MyData
{
string data1…;

string dataN…;
int nun1;
….
};

private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
if (Application ["First"] == null)
{
MyData = InitData ();
InitAppData ()
}
Application ["First "] = 1;
}
}

private struct InitAppData ()
{
Application [“Data1”] = MyData.data1;
……..
Application [“DataN”] = MyData.dataN;
…..
}

The Application objects are available for all sessions with the same values.
Another way is to use the Application_Start event in Global.asax to load the
Application objects.

private void Application_Start (object ob, EventArgs e)
{
MyData = InitData();
InitAppData ();
}
Have a fun!

Valentin

Do not hesitate to contact me!

www.wwv-it.eu
va*************@t-online.de
"ma*************@gmail.com" wrote:
I am new to web services, and wonder if it is possible to have a web
service run all time and start the constructor before anyone calls any
web method. My problem is that a lot of data is read in the
constructor, and if this is to be loaded every time somebody calls a
web method, thing are really slow. I have tried to just call the web
methods, but it seems like the constructor is called every time.

May 10 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jack Smith | last post by:
Hello, I have PHP 4.3.1.1 running on Windows 2000 Server with IIS 5. This connects to an MS SQL 7 server running on a seperate NT4 box. Recently, this SQL7 Server had SQL7 Service Pack 4...
29
by: Ken Allen | last post by:
I have a number of services developed in C# (.Net), and they have been working fine for the most part. Recently someone reported that ipon occassion (originally rarely, but more frequently on some...
20
by: Moty Michaely | last post by:
Hello, Can anyone please help me finding a good way to develop a c# winforms application client for a pre-developed windows service? Should I use wse2 with tcp protocol? Bu I still have win98...
3
by: mamin | last post by:
Hi, I'm trying to write windows service that sending files from server to client. This service will work on serwer side.How windows service on server side can get client address? Is it possible to...
3
by: tshad | last post by:
I created a service in VS 2003 and the code works fine as an application, but not as a service. It installs fine, but when I try to start it, it tells me it was unable to start. Am I missing...
6
by: uuyytt | last post by:
I have a Windows service from which I want to start Internet Explorer with a particular URL as an argument. I don't know why my code (shown below) doesn't work. I know that IExplore.exe starts as I...
0
by: jordo | last post by:
I have an asp.Net app that connects to the WSS 2.0 list web service. I'm having issues with IIS and .Net configurations and hope that someone can help me. My ideal configuration is: asp.net:...
4
by: carson | last post by:
I have written two windows services: - service A does some crunching of local data files and uploads them to a central processing computer via http. - service B monitors a manifest file on a...
4
by: cappjr | last post by:
Here's what I'm trying to do. I have a form with a text box called "accountNum". I have a label under that text box called "orgName". What I want to do, using Web Services, is when the user...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.