WCF决定:一个服务的多个合同或多项服务 [英] wcf decision: one service multiple contracts or many services

查看:200
本文介绍了WCF决定:一个服务的多个合同或多项服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用.NET 4中创建一个客户一个客户端小的服务器应用程序。我应该创建一个实现许多合同(IInvoice,IPurchase,ISalesOrder等),或者我应该创建运行在多个端口每一个合同的许多服务一个巨大的服务?我的问题是特别感兴趣,无论是选择的利弊/利弊。此外,什么是回答这个问题的常见方式?

I am using .NET 4 to create a small client server application for a customer. Should I create one giant service that implements many contracts (IInvoice, IPurchase, ISalesOrder, etc) or should I create many services running one contract each on many ports? My questions specifically is interested in the pros/cons of either choice. Also, what is the common way of answering this question?

我真正的困境是,我没有经验做出这个决定,我有与WCF,我需要帮助理解这样的决定的技术含义很少足够的经验。

My true dilemma is that I have no experience making this decision, and I have little enough experience with wcf that I need help understanding the technical implications of such a decision.

推荐答案

不要创建实现服务合同的正数一个大的服务。这些类型的服务很容易创建,但最终会成为维护的头痛,并不会很好地扩展。此外,你会得到各种code合并冲突,如果有一个开发组办理入住手续的竞争/退房的次数。

Don't create one large service that implements n-number of service contracts. These types of services are easy to create, but will eventually become a maintenance headache and will not scale well. Plus, you'll get all sorts of code merging conflicts if there's a development group competing for check-ins/check-outs.

不要造成太多的服务无论是。避免使您的服务过于细粒度的陷阱。尝试创建基于功能的服务。这些服务公开的方法不应该是细粒度无论是。你最好具有较少的方法做多。避免产生像GetUserByID(INT ID),GetUserByName(String name)通过创建的getUser(userObject用户)类似的功能。您将有code较少,易于维护和更​​好的可发现性。

Don't create too many services either. Avoid the trap of making your services too fine-grained. Try to create services based on a functionality. The methods exposed by these services shouldn't be fine-grained either. You're better off having fewer methods that do more. Avoid creating similar functions like GetUserByID(int ID), GetUserByName(string Name) by creating a GetUser(userObject user). You'll have less code, easier maintenance and better discoverability.

最后,你可能只将需要一个端口,无论你做什么。

Finally, you're probably only going to need one port no matter what you do.

这篇关于WCF决定:一个服务的多个合同或多项服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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