同一合同的两个绑定

时间:2011-01-10 00:08:33

标签: .net wcf wcf-endpoint

我有一份合同,我有一个basicHttpBinding。

            <endpoint address="http://localhost:49654/BookShopService.svc" binding="basicHttpBinding" contract="BookShop.IBookShopService">
            </endpoint>

我想为wsHttpBinding添加另一个端点,用于相同的绑定。 我必须采取哪些步骤?结果地址是什么?

2 个答案:

答案 0 :(得分:2)

只需添加另一个具有不同地址的端点,它应如下所示:

<endpoint address="http://localhost:49654/BookShopService.svc" binding="basicHttpBinding" contract="BookShop.IBookShopService">
</endpoint>
<endpoint address="http://localhost:49654/BookShopServiceWS" binding="wsHttpBinding" contract="BookShop.IBookShopService">
</endpoint>

MSDN上有一个入门。

答案 1 :(得分:1)

如果您在IIS中运行,那么您不应提供完全限定的地址 - 该地址将由IIS确定,因此供应可能会导致部署问题。因此,以Greg Sansom的答案为基础,我建议

<endpoint address="" 
    binding="basicHttpBinding" 
    contract="BookShop.IBookShopService" /> 
<endpoint address="ws" 
    binding="wsHttpBinding" 
    contract="BookShop.IBookShopService" />

其中ws是服务地点的相对地址。

e.g。