2012-12-29 34 views
4

我想將http方案綁定從basicHttpBinding更改爲wsHttpBinding。我知道我可以覆蓋它到app.config。但是,這將需要更改所有受影響的WCF主機應用程序中的設置。WCF中存儲的默認協議映射在哪裏

我也找不到machine.config中的協議映射部分。

默認的協議映射如下。

<protolMapping> 
    <add scheme ="http" binding="basicHttpBinding" bindingConfiguration="" /> 
    <add scheme ="tcp" binding="netTcpBinding" bindingConfiguration="" /> 
.. 
</protocolMapping> 

改變後應該看起來像。

<protolMapping> 
    <add scheme ="http" binding="wsHttpBinding" bindingConfiguration="" /> 
    <add scheme ="tcp" binding="netTcpBinding" bindingConfiguration="" /> 
.. 
</protocolMapping> 
+0

不要發佈代碼的屏幕快照。相反,發佈代碼。如果您不知道如何正確格式化代碼,請單擊格式工具欄右側的大胖橙色問號。 – Charles

+0

編輯並移除屏幕抓圖。 – Tilak

回答

1

我相信默認值在代碼中實現的,而不是在config文件中,如果你看一下ProtocolMappingSection Class,方法InitializeDefault用的工具,如反射器或等價物,你會看到:

protected override void InitializeDefault() 
{ 
    this.ProtocolMappingCollection.Add(new ProtocolMappingElement("http", "basicHttpBinding", "")); 
    this.ProtocolMappingCollection.Add(new ProtocolMappingElement("net.tcp", "netTcpBinding", "")); 
    this.ProtocolMappingCollection.Add(new ProtocolMappingElement("net.pipe", "netNamedPipeBinding", "")); 
    this.ProtocolMappingCollection.Add(new ProtocolMappingElement("net.msmq", "netMsmqBinding", "")); 
} 
1

Defaults在machine.config中設置,如果它們不存在於machine.config中,可以在web.config/app.config中覆蓋它,這可能是因爲服務器未安裝WCF Preinstalled。通常這將被安裝和配置與IIS,但如果IIS沒有安裝或不被用來承載WCF那麼WCF功能不會。

MSDN Link on the subject