是否可以在同一服务上为不同的合同返回不同的wsdl?

时间:2011-10-11 10:23:09

标签: wcf wsdl

我有一个WCF服务在两个不同的端点上实现两个合同。我希望客户端能够指向端点(而不是服务的基地址)并获取wsdl仅用于在该端点上实现的合同(而不是包含所有合同的wsdl)。

这可能吗?如果是这样,怎么能实现呢?

1 个答案:

答案 0 :(得分:2)

而不是如下所示设置服务(如果在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>