WSHttp binding and ReliableSession / MaxRetryCount

我与影子孤独终老i 提交于 2019-11-29 08:05:53

You cannot set the maxRetryCount on a standard wsHttpBinding configuration. In order to set that value, you need to create a separate custom binding and then reference that from your service or client config:

  <system.serviceModel>
    <bindings>
      <customBinding>
        <binding name="wsCustomBinding">
          <reliableSession maxRetryCount="15"/>
          <textMessageEncoding/>
          <httpTransport />
        </binding>
      </customBinding>
    </bindings>
    <services>
      <service name="MyService">
        <endpoint address="http://localhost:7878/MyServoce"
                  binding="customBinding"
                  bindingConfiguration="wsCustomBinding"
                  contract="IMyService" />
      </service>
    </services>
  </system.serviceModel>

Defining a custom binding isn't hard - but you need to make sure you specify the elements that make up the binding in the right order - see the MSDN docs on custom bindings for a reference.

If you want to share the custom binding configuration between server and client, you could also put that <bindings> section into a separate bindings.config file, and then reference that external file from your web.config/app.config:

  <system.serviceModel>
    <bindings configSource="bindings.config">

Visual Studio will complain about this and show red squiggly underlines - but trust me - the technique works, I use it in production every day (the Visual Studio XML schema describing the config stuff isn't complete and accurate).

Marc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!