WSHttp binding and ReliableSession / MaxRetryCount

后端 未结 1 1412
隐瞒了意图╮
隐瞒了意图╮ 2020-12-18 13:10

When using a WSHttpBinding in WCF with reliableSessions enabled, my service reference updates itself to:



        
相关标签:
1条回答
  • 2020-12-18 13:33

    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

    0 讨论(0)
提交回复
热议问题