我已經開發了具有兩個合同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