Windows服务和WCF服务之间的通信 [英] Communication between Windows service and WCF service

查看:437
本文介绍了Windows服务和WCF服务之间的通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在某些情况下,一旦某个外部应用程序触发了事件,我就需要从Windows服务传递数据[Sql].

我对WCF服务的了解不多

我有以下查询
WCF服务和Windows服务之间是否可能具有回调协定?

有人可以指导如何进一步进行

在此先感谢



am in situation where in i need to pass data from windows service once event triggered from some external application[Sql].

i don`t have much idea on WCF services

i have following queries
is it possible to have callback contract between WCF service and Windows service?

Can someone please guide on how to proceed further

thanks in advance

推荐答案

如果您的WCF托管在IIS中,请向Windows服务添加服务引用.现在它将为您创建一个代理.
现在,您必须创建一个回调类,并从WCF服务中实现CallbackContract接口.现在,当您创建服务代理的实例时,必须将此回调实现提供给代理构造函数.现在,当您调用WCF服务时,您将在回调实现中获得回调.
If your WCF is hosted in IIS then add a service reference to your windows service. Now it will create you a proxy.
Now you have to create a callback class and implement your CallbackContract Interface from WCF service. NOw when you create an instance of your service proxy, you have to give this callback implementation to the proxy constructor. Now when you call the WCF service, You will get the callback in your callback implementation.


您能对此进行更具体的说明吗?
您能解释一下您的要求吗?
Can you be more specific on this?
Can you explain your requirement?


您可以做到这一点.
现在告诉我您是否已经有wcf服务?
如果是,则查看服务实现,以了解是否定义了任何回调协议.
回调协定将是回调方法上具有[OperationContract]属性的接口.
服务合同将引用此回调.

现在了解如何托管wcf服务.如果它是在IIS中托管的,则应在应用程序中自行托管...

现在回答我的问题,我可以为您提供帮助.
you can do this.
Now tell me if you have a wcf service already in place?
If yes then have a look into the service implementation to find out if there is any Callback contract defined.
Callback contract will be an Interface with [OperationContract] attribute on the callback methods.
This callback will be refered by the service contract.

Now find out how the wcf service is hosted. If it is hosted in IIS, Self hosted, within application...

Now answer to my questions and i can help you.


这篇关于Windows服务和WCF服务之间的通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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