您不能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 文档以获取参考。
如果您想在服务器和客户端之间共享自定义绑定配置,您还可以将该<bindings>
部分放入单独的bindings.config
文件中,然后从您的 web.config/app.config 中引用该外部文件:
<system.serviceModel>
<bindings configSource="bindings.config">
Visual Studio 会对此抱怨并显示红色波浪下划线 - 但相信我 - 该技术有效,我每天都在生产中使用它(描述配置内容的 Visual Studio XML 模式并不完整和准确)。
马克