为 wsHttpBinding 分配自定义绑定配置

Assign a custom binding configuration for wsHttpBinding

我 运行 遇到了一些问题,我认为这是一个非常简单的问题。

尝试通过 WCF 发送 "large" 消息时,出现错误:

The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quote, use the MaxReceivedMessageSize property on the appropriate binding element.

为了解决这个问题,我创建了一个具有更高 MaxReceivedMessageSize 值的自定义绑定配置。但是我仍然得到错误,好像没有读取值。

这是我的服务器App.config:

<system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="largeBinding" maxReceivedMessageSize="2147483647">
          <readerQuotas maxArrayLength="2147483647"/>
        </binding>
      </wsHttpBinding>
    </bindings>
    <services>
      <service name="EMS.Services.TradeController">
       <endpoint address="http://localhost:9002/TradeService"
                  binding="wsHttpBinding"
                  bindingConfiguration="largeBinding"
                  contract="EMS.Contracts.Services.ITradeService"/>
      </service>
    </services>
  </system.serviceModel>

这是我的客户 App.config:

<system.serviceModel>
<bindings>
  <wsHttpBinding>
    <binding name="largeBinding" maxReceivedMessageSize="2147483647">
      <readerQuotas maxArrayLength="2147483647"/>
    </binding>
  </wsHttpBinding>
</bindings>
<client>
  <endpoint address="http://localhost:9002/TradeService"
            binding="wsHttpBinding"
            bindingConfiguration="largeBinding"
            contract="EMS.Contracts.Services.ITradeService"/>
</client>

我是否缺少正确分配绑定的部分?

客户端的配置是Adding Service Reference工具自动生成的吗?我怀疑客户端代理是否使用 Wshttpbinding 创建的服务端点。您当前的配置似乎没有任何内容。
此外,请考虑配置其他属性。

     <wsHttpBinding>
        <binding name="largeBinding" allowCookies="true"
 maxReceivedMessageSize="20000000"
 maxBufferSize="20000000"
 maxBufferPoolSize="20000000">
          <readerQuotas maxDepth="32"
 maxArrayLength="200000000"
 maxStringContentLength="200000000"/>
        </binding>
      </wsHttpBinding>

MaxBufferSizeReaderQuotas属性也需要配置
MaxBufferSize
ReaderQuotas
如果问题仍然存在,请随时告诉我。