C#中如何初始化的WebService [英] C# How to initialize WebService

查看:2346
本文介绍了C#中如何初始化的WebService的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能来初始化一个WebService。

Is there a possibility to initialize a WebService.

我在寻找,只有到WebService的第一次调用过程中运行的方法。有没有类似的东西在.net中?

I'm searching for a method that runs only during first call to WebService. Is there something like it in .Net ?

推荐答案

这是我对你的问题的评论继....

Following on from my comment on your question....

如果您需要初始化第一次给定的客户端连接到Web服务: 有一个初始化方法,该方法返回一个标记,例如AA的GUID,然后将其在每次调用的实际需要作出做工作Web服务的方法。然后,您可以确保该客户端的服务总是初始化。

If you require "initialization" the first time a given client connects to the Web Service: Have an "Initialize" method that returns a token, such a a Guid, that is then required on every call made to the actual "does the work" method of your web service. You can then ensure that for that client the service is always initialized.

如果你需要它的第一次Web服务的要求不断呼吁: 添加一些code为您服务,作为一家民营的方法,即所谓的在每一个公共方法的顶部。在它检查的东西,是否存在等,如注册表项,文件,数据库记录或其他持续性的价值。如果它不存在,执行您的初始化,然后创建的东西。

If you require it the first time the web service is ever called: Add some code to your service, as a private method, that is called at the top of each public method. Within it check for the existance of something, such as a registry entry, file, database record or other persistant value. If it doesn't exist, perform your initialisation and then create the "something".

如果你需要它,因为IIS中的第一次调用最后回收/启动应用程序池: 有一个静态构造函数的类,这样,当它的第一个实例化的静态构造函数运行,并执行你的初始化。

If you require it on the first call since IIS last recycled/started the Application Pool: Have a static constructor for the class so that when it's first instantiated the static constructor runs and performs your initialisation.

这篇关于C#中如何初始化的WebService的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆