我想在IIS中托管服务时调用方法 [英] I want to calls method while hosting a service in IIS

查看:76
本文介绍了我想在IIS中托管服务时调用方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





和C#中的构造函数一样,我希望在IIS中托管时调用WCF服务中的方法。

Hi,

Like constructor in C#, I want ot call a method in WCF service when it is hosted in IIS.

推荐答案

完全就像C#中的构造函数一样,但也许你正在寻找客户端激活。在所有情况下,您需要了解WCF 激活远程对象

http://msdn.microsoft.com/en-us/library/cbzcxy2s%28v=vs.100%29.aspx [ ^ ]。



但是,我不知道你的目标。也许,在您的设计中,您可以简单地使用这样的技术在服务器端创建一些对象的实例,就像在客户端请求上触发的对某些远程对象方法的调用的副作用一样。有关一些想法,另请参阅:

http://en.wikipedia.org/wiki/Factory_method_pattern [ ^ ]。



小心:对于WCF来说,在单一过程的情况下,这在架构上更加困难,这就是为什么我引用该模式主要是为了思考的食物。



-SA
Nothing is exactly "like a constructor in C#", but maybe you are looking for the client activation. In all cases you need to learn about WCF Activation of Remote Objects:
http://msdn.microsoft.com/en-us/library/cbzcxy2s%28v=vs.100%29.aspx[^].

However, I don't know your goal. Perhaps, in your design you can simply use such technique as creation of instanced of some objects on server side just as a side effect of the call to some remote object methods, triggered on the client request. For some ideas, see also:
http://en.wikipedia.org/wiki/Factory_method_pattern[^].

Be careful: with WCF, it's architecturally way more difficult then with single-process situation, that's why I referenced the pattern mostly for the food for the for thought.

—SA


使用这样的代码



Am using code like this

ServiceHost serviceHost;
            serviceHost = new ServiceHost(typeof(Wcf.CustomeService));
            serviceHost.Open();





它不起作用



it's not working


这篇关于我想在IIS中托管服务时调用方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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