您不能设置
maxRetryCount
关于标准
wsHttpBinding
配置。为了设置该值,需要创建一个单独的自定义绑定,然后从服务或客户机配置中引用该绑定:
<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>
定义自定义绑定并不困难,但您需要确保按正确的顺序指定组成绑定的元素-请参见
MSDN docs on custom bindings
作为参考。
如果要在服务器和客户机之间共享自定义绑定配置,也可以将其
<bindings>
分成一个单独的部分
bindings.config
文件,然后从web.config/app.config引用该外部文件:
<system.serviceModel>
<bindings configSource="bindings.config">
Visual Studio会抱怨这一点,并显示出红色的弯弯曲曲的下划线——但请相信我——这项技术是有效的,我每天都在生产中使用它(描述配置的Visual Studio XML模式并不完整和准确)。
马克