Jan*_*oom 3 wcf ws-reliablemessaging wshttpbinding
在WSHttpBinding启用了reliableSessions的WCF中使用时,我的服务引用会将自身更新为:
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="true">
</reliableSession>
Run Code Online (Sandbox Code Playgroud)
maxRetryCount只要将绑定配置为WSHttpBinding,我就无法将该属性添加到reliableSession.
现在我的问题是:maxRetryCount使用WSHttpBinding时的价值是什么,有没有办法在配置中改变它; 不使用CustomBinding?
您无法设置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>
Run Code Online (Sandbox Code Playgroud)
定义自定义绑定并不难 - 但是您需要确保以正确的顺序指定组成绑定的元素 - 请参阅有关自定义绑定的MSDN文档以获取参考.
如果要在服务器和客户端之间共享自定义绑定配置,还可以将该<bindings>部分放入单独的bindings.config文件中,然后从web.config/app.config引用该外部文件:
<system.serviceModel>
<bindings configSource="bindings.config">
Run Code Online (Sandbox Code Playgroud)
Visual Studio会抱怨这个并显示红色波浪形下划线 - 但相信我 - 这项技术有效,我每天都在生产中使用它(描述配置内容的Visual Studio XML模式不完整和准确).
渣
| 归档时间: |
|
| 查看次数: |
6042 次 |
| 最近记录: |