是否可以在服务的Web.config文件中定义默认客户端绑定配置?
我想指定默认的maxReceivedMessageSize和maxBufferPoolSize值,以便客户端不需要不断更改默认值
有些事情(这不起作用):
<bindings>
<wsHttpBinding >
<binding name="Standard" maxReceivedMessageSize="6000000" maxBufferPoolSize="200000000" >
<readerQuotas maxDepth="32" maxBytesPerRead="200000000"
maxArrayLength="200000000"
maxStringContentLength="200000000"/>
<security mode="TransportWithMessageCredential" />
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint binding="wsHttpBinding"
bindingConfiguration="Standard"
contract="SomeContract" />
</client>
答案 0 :(得分:3)
在WCF 4(.NET 4)中 - 是:只需将name=
属性留空(或省略name=
属性) - 所以使用
<bindings>
<wsHttpBinding >
<binding
maxReceivedMessageSize="6000000" maxBufferPoolSize="200000000" >
<readerQuotas maxDepth="32" maxBytesPerRead="200000000"
maxArrayLength="200000000" maxStringContentLength="200000000"/>
<security mode="TransportWithMessageCredential" />
</binding>
</wsHttpBinding>
</bindings>
然后这些设置适用于该配置文件中端点使用的所有wsHttpBinding
。
在此处阅读有关WCF 4中的新功能的更多信息:A Developer's Introduction to WCF 4 - 此处也列出了默认的绑定和行为配置(距离顶部不太远)。