初学者WCF问题 - 消耗品异步服务消耗品、初学者、问题、WCF

2023-09-03 11:41:48 作者:逐流清风

这是一个更能不能做到,而不是如何做的问题。我期待在构建将在不同的平台上使用多个内部客户系统服务(中间层,.NET,提供数据抽象和一些业务逻辑)。例如。一个客户可能是一个网站,另一个客户端一些Java code,另一个客户端C#等。

this is a more "can it be done" rather than a "how is it done" question. I'm looking at building a service (middle tier, .net, providing data abstraction and some business logic) that will be used by multiple internal client systems on different platforms. E.g. one client might be a web site, another client some java code, another client C#, etc.

我想提供一个同步和异步API为我服务,例如:的GetData,BeginGetData,EndGetData方法。我也希望客户能够注册为新的数据的通知被添加到系统中。在过去,我曾与一个TIBCO EMS渠道通知实施这一使用Web服务。

I want to provide a synchronous and asynchronous API into my service, e.g. GetData, BeginGetData, EndGetData methods. I also want clients to be able to register for notifications of new "data" being added to the system. In the past I've implemented this using web services with a Tibco EMS channel for the notifications.

我的问题是:我能达到三个要求(同步,异步,和发布/订阅)暴露WCF服务?难道这种服务所消耗非WCF客户端?

My question is: Could I achieve the three requirements (synch, asynch, and pub/sub) by exposing a WCF service? Could this service by consumed by non WCF clients?

请问这个问题的模糊性 - 如需要,我可以详细说明

Excuse the vagueness of this question - I can elaborate as needed.

在此先感谢。

推荐答案

方法是同步的默认。为了让他们异步,你需要添加这个属性[OperationContract的(AsyncPattern = TRUE)],并返回一个IAsynchResult,就像你,如果你是用的WinForms做BeginIvoke()。 (在这里阅读更多 http://msdn.microsoft.com/en-us/library /ms734701.aspx )

Methods are synchronous by default. To make them asynch, you need to add this attribute [OperationContract(AsyncPattern=true)] and return an IAsynchResult, just like you would if you were doing BeginIvoke() with winforms. (read more here http://msdn.microsoft.com/en-us/library/ms734701.aspx)

您可以不发布/有一种叫做回调合同订阅(虽然林不知道有关在其他平台上实现这一点)我没有与这些太多的经验,但他们似乎并不巨大肤色的(你可以阅读更多在这里 http://dotnetaddict.dotnetdevelopersjournal.com/wcf_alarmclock.htm )

You can do publish/subscribe with something called a Callback Contract (although im not sure about implementing this in other platforms) I don't have much experience with these, but they don't seem hugely complected(you can read more here http://dotnetaddict.dotnetdevelopersjournal.com/wcf_alarmclock.htm)