.net – 存储在WCF中的默认协议映射在哪里

我想将http方案绑定从basicHttpBinding更改为wsHttpBinding.我知道我可以将其覆盖到app.config中.但这需要更改受影响的所有WCF主机应用程序中的设置.

我也找不到machine.config中的协议映射部分.

默认protol映射如下.

<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>

最佳答案 我相信默认值是在代码中实现的,而不是在.config文件中实现,如果你使用Reflector等工具查看
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", ""));
}
点赞