WCF:是否可以在服务的 Web.config 中指定默认客户端配置设置?



是否可以在服务的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>

在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>

然后这些设置应用于该配置文件中端点使用的所有CCD_ 3。

在这里阅读更多关于WCF 4的新功能:开发人员对WCF 4的介绍-默认绑定和行为配置也在那里列出(离顶部不远)。

最新更新