返回首页

介绍
在某些情况下,你必须建立你自己的绑定额外的运输协议,安全性等,在WCF中,你可以轻松地创建自定义绑定使用配置和自定义实现。通过下列选项的更多信息。这是我原来的职位相同。选项​​1:使用配置

<customBinding>

    <binding name="myCustomHttpBinding">

        <binaryMessageEncoder />

        <httpTransport / >

    </binding >    

</customBinding >
选项​​2:编程{C}选项​​3:自实施
public class MyCustomBinding : Binding

{

    private HttpTransportBindingElement transport;

    private BinaryMessageEncodingBindingElement encoding;



    public MyCustomBinding()

           : base()

    {

      this.InitializeValue();

    }

    public override BindingElementCollection CreateBindingElements()

    {

      BindingElementCollection elements = new BindingElementCollection();

      elements.Add(this.encoding);

      elements.Add(this.transport);

      return elements;

    }

    public override string Scheme

    {

      get { return this.transport.Scheme; }

    }

    private void InitializeValue()

    {

      this.transport = new HttpTransportBindingElement();

      this.encoding = new BinaryMessageEncodingBindingElement();

    }

}

如果你想通过配置使用自定义绑定,您必须延长如下的BindingCollectionElement抽象基类:{体C3}
属性,你必须实现的bindingType。它允许定义当前配置的绑定类型目标。其他重要的属性是ConfiguredBindings检索所有的绑定配置元素。 使用配置MyCustomBinding,{的C4}其他WCF文章{A}{A2的}{A3的}{A4纸}{A5的}{A6的}结论
我希望你得到了一些关于WCF自定义绑定和其配置的想法。感谢您阅读:-):

回答

评论会员: 时间:2