WCF(服务器端)的会议驱动配置
-
15-11-2019 - |
题
刚刚开始新的项目,并为WCF项目打开了一个1600行生成的,其中90%的服务相同(HMFPH)。
我喜欢一个易于管理的项目,尽可能少量冗余代码行。因此,我的问题是通过使用常规驱动配置可以配置多个WCF服务。
类似流畅的nhibernate automapper,可以在需要时创建覆盖(如自定义端点等)。有什么想法吗?
/ jasper
解决方案
WCF in .NET 4 has a lots of convention-based configuration - as long as you don't start specifying your own stuff, each service defined in your web.config
will get a default endpoint for each of the base addresses defined in your web.config
- that alone can cut out 50-80% of your config.
Furthermore, you can define default behaviors, e.g. for your services; things like always expose metadata and make it available from HTTP and so forth can be defined once, as a "template" behavior and will be applied to all service entries without further ado.
Check out all the details of what's new in WCF 4 and how to make use of the convention-driven configuration ("no config WCF") here: A Developer's Introduction to WCF 4