【问题标题】:WCF MaxReceivedMessageSize not working correctly (not being read)WCF MaxReceivedMessageSize 无法正常工作(未被读取)
【发布时间】:2015-09-10 07:23:13
【问题描述】:

我有一个 WCF 服务,我试图在其中提取某个 XML 文件,并将该文件发送到客户端,但我不断收到此错误:

已超出传入邮件的最大邮件大小配额 (65536)。要增加配额,请在适当的绑定元素上使用 MaxReceivedMessageSize 属性。

我在 app.config 中更改了 maxReceivedMessageSize

App.config

端点配置

<services>
  <service name="MobileReportService.Service" behaviorConfiguration="ServiceBehavior">
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost:8733/Design_Time_Addresses/MobileReportService/Service/" />
      </baseAddresses>
    </host>
    <endpoint name="ServiceEndpoint"
            binding="basicHttpBinding"
            contract="MobileReportService.IService">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
</services>

绑定配置

<bindings>
  <basicHttpBinding>
    <binding maxBufferPoolSize="5242880" maxBufferSize="5242880"
      maxReceivedMessageSize="5242880" />
  </basicHttpBinding>
</bindings>

我不太明白为什么maxReceivedMessageSize 无法读取?

编辑

我正在通过每次运行服务时出现的弹出窗口测试服务,方法是按“调用”

【问题讨论】:

    标签: wcf exception maxreceivedmessagesize


    【解决方案1】:

    您需要删除绑定名称。除非您定义多个 basicHttpBinding 配置,否则无需定义绑定名称。如果删除名称,则定义的设置将应用于使用绑定类型的所有端点。

    <bindings>
      <basicHttpBinding>
        <binding maxReceivedMessageSize="(big number)" />
      </basicHttpBinding>
    </bindings>
    

    【讨论】:

    • 检查主要问题编辑。这是我测试的地方,所以没有真正的客户端。这是在服务器端制作的
    • @Detilium 你删除了绑定名称(binding1)吗?
    • 您可以编辑 WCF 测试客户端的配置文件。右键单击左窗格中的 Config File 节点,然后选择 Edit with ScvConfigEditor。
    • @TomRedfern - maxReceivedMessageSize 仅适用于服务或客户端(取决于您正在谈论的配置文件)。如果服务的响应太大而客户端无法使用,则在服务端设置增加的 maxReceivedMessageSize 将无济于事。
    • @TomRedfern 是的,我做到了。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-11-23
    • 2012-01-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-14
    • 1970-01-01
    相关资源
    最近更新 更多