【发布时间】:2011-10-11 10:23:09
【问题描述】:
我有一个 WCF 服务在两个不同的端点上实现两个合同。我希望客户端能够指向一个端点(而不是服务的基地址)并获取仅用于在该端点上实现的合同的 wsdl(而不是包含所有合同的 wsdl)。
这可能吗?如果可以,如何实现?
【问题讨论】:
我有一个 WCF 服务在两个不同的端点上实现两个合同。我希望客户端能够指向一个端点(而不是服务的基地址)并获取仅用于在该端点上实现的合同的 wsdl(而不是包含所有合同的 wsdl)。
这可能吗?如果可以,如何实现?
【问题讨论】:
而不是如下所示设置服务(如果托管在 IIS 中,则使用单个 SVC 文件)
<services>
<service name="YourOrg.YourService">
<endpoint address=""
binding="wsHttpBinding"
contract="YourOrg.IYourServiceThisContract" />
<endpoint address="That"
binding="wsHttpBinding"
contract="YourOrg.IYourServiceThatContract" />
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange"/>
</service>
</services>
将每个合同设置为单独的服务类(在同一个 IIS 网站中具有自己的 SVC 文件)
<services>
<service name="YourOrg.ThisService">
<endpoint address=""
binding="wsHttpBinding"
contract="YourOrg.IYourServiceThisContract" />
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange"/>
</service>
<service name="YourOrg.ThatService">
<endpoint address=""
binding="wsHttpBinding"
contract="YourOrg.IYourServiceThatContract" />
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange"/>
</service>
</services>
【讨论】: