2012-07-18 54 views
1

首先有點背景:如何在使用ASP .NET託管時在WCF中設置Net命名管道的名稱?

我有一個web服務器,它運行同一個ASP .NET應用程序的每一個在不同的文化(在web.config中設置)的4個實例。這些文化是英國(GBR),澳大利亞(AUS),愛爾蘭(IRL)和新西蘭人(NZL)。他們每個人都有一個web方法「DoWork」,我想通過一個計劃任務調用它。我有一個簡單的exe即要求四個文化的這種方法,簡化代碼:

Dim AUSclient As New AUSAutomated.AUSAutomatedClient() 
AUSclient.DoWork 
Dim GBRclient As New GBRAutomated.GBRAutomatedClient() 
GBRclient.DoWork 
Dim IRLclient As New IRLAutomated.IRLAutomatedClient() 
IRLclient.DoWork 
Dim NZLclient As New NZLAutomated.NZLAutomatedClient() 
NZLclient.DoWork 

其中消耗的app.config像這樣的方法的任務:

 <endpoint address="net.pipe://localhost/Services/GBR/GBRAutomated.svc" 
      binding="netNamedPipeBinding" bindingConfiguration="NetNamedPipeBinding_IGBRAutomated" 
      contract="GBRAutomated.IGBRAutomated" name="NetNamedPipeBinding_IGBRAutomated"> 
       </endpoint> 

     <endpoint address="net.pipe://localhost/Services/IRL/IRLAutomated.svc" 
binding="netNamedPipeBinding" bindingConfiguration="NetNamedPipeBinding_IIRLAutomated" 
contract="IRLAutomated.IIRLAutomated" name="NetNamedPipeBinding_IIRLAutomated"> 
        </endpoint> 

     <endpoint address="net.pipe://localhost/Services/NZL/NZLAutomated.svc" 
      binding="netNamedPipeBinding" bindingConfiguration="NetNamedPipeBinding_INZLAutomated" 
      contract="NZLAutomated.INZLAutomated" name="NetNamedPipeBinding_INZLAutomated"> 
        </endpoint> 

該應用程序通過使用網絡命名管道綁定通過WCF公開Web方法。每種文化都在web.config中有一個條目指向正確的服務。例如愛爾蘭人是:

<service name="Web.IRLAutomated"> 
      <endpoint address="net.pipe://localhost/Services/IRL/IRLAutomated.svc" binding="netNamedPipeBinding" contract="Web.IIRLAutomated" /> 
     </service> 

因此,每種文化的暴露方法有不同的合同和地址。

當任務運行時,它會全部調用澳大利亞方法4次。它似乎忽略了web.configs中的設置,並在第一個應用程序中使用正確的合同調用該方法。所以我的問題是:

如何爲每種文化中的方法設置唯一的管道名稱?

我試着在綁定上設置hostNameComparisonMode =「Exact」,但這似乎沒有任何區別。

回答

0

你不能

經過一番搜索,我發現這裏StackOverflow上一個類似的問題:

controlling the name of a named pipe when hosting WCF net.pipe binding in IIS

正如沒有人回答了上述問題在2年內我假設我想做什麼是不可能的。

如果任何人與這類問題所困擾,我發現這個博客條目幫助我瞭解非常有幫助:

http://blogs.charteris.com/blogs/chrisdi/archive/2008/05/19/exploring-the-wcf-named-pipe-binding-part-1.aspx

我要更改綁定到HTTP,這將解決我的問題。