“已超出传入邮件的最大邮件大小限额(65536)。”即使设定了更大的尺寸

时间:2013-08-25 15:26:43

标签: c# .net winforms wcf web-services

我正在尝试从Windows窗体客户端应用程序访问WCF服务。我在服务器上的绑定配置是:

 <bindings>
      <customBinding>
        <binding name="Wrabind" closeTimeout="00:05:00" openTimeout="00:05:00"
            sendTimeout="00:25:00">
          <textMessageEncoding />
          <security authenticationMode="SecureConversation" includeTimestamp="true"
              messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10">
            <localClientSettings maxClockSkew="00:30:00" />
            <localServiceSettings maxClockSkew="00:30:00" />
            <secureConversationBootstrap messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10">
              <localClientSettings maxClockSkew="00:30:00" />
              <localServiceSettings maxClockSkew="00:30:00" />
            </secureConversationBootstrap>
          </security>
          <httpTransport maxBufferPoolSize="20000000" maxReceivedMessageSize="20000000"
              allowCookies="true" maxBufferSize="20000000" />
        </binding>
      </customBinding>
    </bindings>

正如您所看到的,我已将maxReceivedMessageSize设置为20000000,但仍显示"The maximum message size quota for incoming messages (65536) has been exceeded."例外。我错过了什么吗?

3 个答案:

答案 0 :(得分:6)

也许这个错误来自客户端而不是服务器。确保客户端配置中存在相同的设置。

答案 1 :(得分:2)

在这种情况下,WCF服务器端设置无关紧要。客户端绑定配置是你的敌人...

答案 2 :(得分:1)

来自here: -

您可能还需要添加“binding.MaxBufferSize = 2147483647”。更新或重新配置服务引用后,“ServiceReferences.ClientConfig”将自动更新。因此,如果您使用WCF服务lib的“App.config”在服务级别提供了正确的绑定配置,则该配置将自动继承到消费的silverlight客户端。但是如果你在代码中动态创建绑定,所有这些都不会生效。