我们有需要提供下列服务:
现在,我通过在WCF服务项目中创建SVC文件实现了#1。它们是在配置文件中配置的。我没有在本节中指定任何内容,似乎SVC文件使用默认绑定(没有name属性的绑定)。这听起来对吗?
如果我要实现其他类型的服务,我需要在web.config中的部分中指定服务并指向它们的特定绑定/行为,或者创建三个单独的服务项目。最好的做法是什么?
我们希望使用T4模板自动生成服务( svc文件)。到目前为止,这是可行的,但是如果我继续的话,我必须生成web.config文件(这会使维护变得很困难)。是否有任何方法可以分割出配置文件的system.service模型部分?
谢谢。
发布于 2011-06-16 13:42:22
web.config (和app.config)文件可以分割成单独的文件,如下所示。如果需要的话,可以封装整个system.serviceModel元素。
<system.serviceModel>
<services configSource="services.config" />
<behaviors configSource="behavior.config" />
<bindings>
<wsHttpBinding>
<binding name="Http" receiveTimeout="00:10:00">
<security mode="None">
<transport clientCredentialType="None" />
<message clientCredentialType="None" establishSecurityContext="false" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<!-- rest of WCF elements inline as in the bindings element or in other files -->
</system.serviceModel>您只需要创建每个引用的文件。这是一种很好的方法,可以将环境(即Dev、QA、暂存、Prod)特定的设置放在单独的文件中,这样您就可以将部署脚本参数化。
https://stackoverflow.com/questions/6372598
复制相似问题