2011-01-10 58 views
0

同我有合同,我有一個basicHttpBinding的。兩個綁定合同

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

我想添加另一個端點wsHttpBinding,爲相同的綁定。 什麼是我必須採取的步驟?結果地址是什麼?

回答

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

如果您在IIS中運行,那麼你不應該提供一個完全合格的地址 - 該地址將被IIS來決定,因此提供一個可導致部署問題。因此,使用格雷格桑塞姆的回答爲基礎,我建議

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

其中ws是服務位置相對地址。

例如