【问题标题】:IBindingConfigurationElement - How to implement and add to configuration?IBindingConfigurationElement - 如何实现和添加到配置?
【发布时间】:2011-10-28 03:51:17
【问题描述】:

我正在尝试使用自定义绑定来扩展 WCF,这需要我替换 WCF 堆栈中的消息格式、编码和安全元素。为了便于使用此绑定,我想以与内置绑定相同的方式从配置文件中对其进行配置(即命名元素,而不是 customBinding)。

WCF 标准绑定都继承自StandardBindingElement,后者又实现了IBindingConfigurationElement。如果我实现了这个接口或者继承自类,如何让配置元素对 WCF 配置系统可用?

【问题讨论】:

    标签: wcf configuration binding


    【解决方案1】:

    http://blogs.msdn.com/b/carlosfigueira/archive/2011/07/26/wcf-extensibility-binding-and-binding-element-configuration-extensions.aspx 的帖子讨论了为绑定和绑定元素添加配置扩展,您应该在那里找到更多信息。

    【讨论】:

      【解决方案2】:

      我做了一些挖掘,在 MSDN 上找到了 bindingExtensions 元素。尽管那里的文档表明您可以通过这种方式添加绑定,但我查看了我的 machine.config 文件并发现其中注册了以下 3.5 绑定:

      <bindingExtensions>
          <add name="wsHttpContextBinding" type="System.ServiceModel.Configuration.WSHttpContextBindingCollectionElement, System.WorkflowServices, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
          <add name="netTcpContextBinding" type="System.ServiceModel.Configuration.NetTcpContextBindingCollectionElement, System.WorkflowServices, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
          <add name="webHttpBinding" type="System.ServiceModel.Configuration.WebHttpBindingCollectionElement, System.ServiceModel.Web, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
          <add name="basicHttpContextBinding" type="System.ServiceModel.Configuration.BasicHttpContextBindingCollectionElement, System.WorkflowServices, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
      </bindingExtensions>
      

      这些类用作绑定元素的集合,继承自奇怪的 StandardBindingCollectionElement&lt;TStandardBinding, TBindingConfiguration&gt; 类。这看起来是正确的类,可以继承并创建关联的StandardBindingElement

      集合使用上面列出的语法注册,然后应该与内置 WCF 绑定完全相同。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2020-03-12
        • 2013-01-27
        • 2013-06-16
        • 1970-01-01
        • 1970-01-01
        • 2017-03-27
        相关资源
        最近更新 更多