我已经开发了具有两个合同Contract1和Contract2暴露在两个不同端点的WCF服务消费WCF服务。 当我要添加对我的客户端应用程序的引用时,它允许我使用这两个合同。限制客户端应用程序上只有一个端点
我如何限制客户端应用程序只使用一个合同?
这里是我的web.config代码提前
<system.serviceModel>
<services>
<service behaviorConfiguration="MyWCFService.Service1Behavior"
name="MyWCFService.Service1">
<host>
<baseAddresses>
<add baseAddress="http://localhost:1010/Service1.svc"/>
</baseAddresses>
</host>
<endpoint address="/MyService1" binding="wsHttpBinding" contract="MyWCFService.IService1" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<endpoint address="/MyService2" binding="wsHttpBinding" contract="MyWCFService.IService2" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyWCFService.Service1Behavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
感谢。
+1这是一个有效的解决方案。如果您不想将第二份合同暴露给第一份合同的客户,请不要在相同的服务中实施它们。这将为您节省大量的工作 - 更多的是在同一服务中实施这些合同可能没有附加价值。 – 2011-01-21 09:04:20