使用 WCF WebApi 的异步 REST 服务
我想知道各位开发人员对 WCF WebApi 服务有何看法。
在 N 层应用程序中,我们可以拥有多层服务。我们可以让服务使用来自外部服务的数据。在这种情况下,值得使用 WCF 4.0 创建异步休息服务。
public interface IService
{
[OperationContractAttribute(AsyncPattern = true)]
IAsyncResult BeginGetStock(string code, AsyncCallback callback, object asyncState);
//Note: There is no OperationContractAttribute for the end method.
string EndGetStock(IAsyncResult result);
}
但随着 WCF WebApi 的发布,这种方法仍然需要吗?创建异步服务?
如何在 IIS/WAS/自托管 中托管它们,
期待建议和评论。
I want to know what is the opinion of you fellow Developers regarding WCF WebApi services.
In an N-tier application we can have multiple layers of services. We can have services consuming data from external services. In that scenario its worth to create Async Rest Services using WCF 4.0.
public interface IService
{
[OperationContractAttribute(AsyncPattern = true)]
IAsyncResult BeginGetStock(string code, AsyncCallback callback, object asyncState);
//Note: There is no OperationContractAttribute for the end method.
string EndGetStock(IAsyncResult result);
}
But with the release of WCF WebApi this approach is still required? to create async services?
How to host them in IIS/WAS/Self Hosting
looking forward for suggestion and comments.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
嗯,我的感觉是,为了在最新的 WCF WebAPI(预览版 6)中创建异步操作,我仍然可以使用相同的模式(开始/结束),但我也可以使用任务编程模型来创建异步操作,这很多更简单。
下面显示了使用任务模型编写的异步操作的一个示例。
Well What i feel,In order to create asynchronous operations in the latest WCF WebAPIs (preview 6) I can still use same pattern (Begin/End), but I can also use the Task programming model to create asynchronous operations, which is a lot simpler.
One example of an asynchronous operation written using the task model is shown below.
WCF Web API 附带完全异步的 HttpClient 实现,您可以在 IIS 中托管,也可以完全在 sefhost 中托管。
对于异步 REST“服务”场景,请阅读“慢速 REST ”
WCF Web API comes with an completely async HttpClient implementation and you can host in IIS and also completely sefhost.
For a async REST "service" scenario please read "Slow REST"