使用自定义绑定

使用自定义绑定和WCF自带的绑定协议配置上没有太大区别,主要有两点不通;

1、需要在配置中指定传输绑定元素

2、如果只有在众多服务中只有一个服务使用自定义绑定,则需要将自定义绑定应用到服务上。

配置如下;

  <system.serviceModel>
    <bindings>
      <customBinding>
        <binding name="customerBinding">
          <httpTransport/>
        </binding>
      </customBinding>
    </bindings>
    <services>
      <service name="Service.AddService">
        <endpoint address="http://127.0.0.1:8088/AddService" 
                  binding="customBinding" 
                  contract="Contract.IAdd" bindingConfiguration="customerBinding" ></endpoint>
      </service>
    </services>
  </system.serviceModel>

注意以上配置中httpTransport是必须要求配置的,因为他是必须的绑定元素(编码绑定元素与传输绑定元素)之一

原文地址:https://www.cnblogs.com/tyb1222/p/3514224.html