开发者

WCF Service Start

I have a wcf service and i want to call a method automatically , immedi开发者_如何学JAVAately after the publishing in IIS. Like an initialization of the WCF service without having to call the method manually or from somewhere else. Where should i place my Initialize method in WCF Service in order to run exactly after the start of the application?


If you're hosting in IIS you can use the application_start event within the Global.asax of the web app that hosting tHE WCF service to do any application initialization. If you are trying to call one of your services when it is first installed then this is likely the wrong approach.

What is the motivation for running some code on start up of the web service? If you are trying to get around a slow initial call to the WCF service I suggest you would want to do some work on the WCF client-side rather than in the service...but Im just guessing at your motivation here


Initialization of the WCF service? So do you have singleton service or do you want to initialize some global state? Otherwise initialization doesn't make sense because service instances will be created for actual clients.

By default IIS starts application when it is accessed first time. If you place initialization in Application_Start (HttpApplication or Global.asax) the code will run when the application is first accessed. But accessing the service is not something that your application can initiate.

IIS 7.5 (Windows 2008 R2) has warm-up module which can run some code when pool is recycled or worker is restarted. If you use other version of IIS you have to use some external solution like custom application pinging your service in regular intervals.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜