【问题标题】:Where is default protocol mapping stored in WCFWCF 中存储的默认协议映射在哪里
【发布时间】:2012-12-29 19:40:46
【问题描述】:

我想将http 方案绑定从basicHttpBinding 更改为wsHttpBinding。我知道我可以将其覆盖为app.config。但这需要更改所有受影响的 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>

【问题讨论】:

  • 不要发布代码的屏幕截图。相反,发布代码。如果您不知道如何正确格式化代码,请点击格式化工具栏右侧的大橙色问号。
  • 编辑和删除屏幕截图。

标签: .net wcf wcf-binding


【解决方案1】:

我相信默认值是在代码中实现的,而不是在 .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", ""));
}

【讨论】:

    【解决方案2】:

    默认值在 machine.config 中设置,如果 machine.config 中不存在默认值,可以在 web.config / app.config 中覆盖,这可能是因为服务器未设置 WCF 预安装。通常这将使用 IIS 进行安装和配置,但如果 IIS 未安装或未用于托管 WCF,则不会使用 WCF 功能。

    MSDN Link on the subject

    【讨论】:

      猜你喜欢
      • 2017-03-04
      • 2017-01-02
      • 1970-01-01
      • 2018-08-19
      • 2019-07-27
      • 1970-01-01
      • 2015-11-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多