【问题标题】:Error:The Maximum message size quota for incoming messages错误:传入邮件的最大邮件大小配额
【发布时间】:2011-10-18 02:41:03
【问题描述】:

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

我已经提到了代理的价值。我需要在服务器端 WCF Web.Config 中提及吗?如果是,那我可以知道怎么做吗?

下面提到了我的 WCF Web.Config。

<binding name="NewBinding0" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" maxReceivedMessageSize="20000000">                
  <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
  <reliableSession enabled="true" />
    <security mode="None">
      <transport clientCredentialType="None" />
      <message clientCredentialType="Windows" negotiateServiceCredential="true" establishSecurityContext="false" />
    </security>
  </binding>

我的客户端编码。

WSHttpBinding binding = new WSHttpBinding();
//binding.ReaderQuotas.MaxArrayLength = 10485760;
//binding.MaxReceivedMessageSize = 10485760;
binding.Security.Mode = SecurityMode.None;
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
binding.Security.Message.ClientCredentialType = MessageCredentialType.Windows;
binding.Security.Message.EstablishSecurityContext = false;
//binding.Security.Message.NegotiateServiceCredential = true;
binding.ReliableSession.Enabled = true;
binding.ReaderQuotas.MaxArrayLength = 2147483647;
binding.ReaderQuotas.MaxDepth = 2147483647;
binding.ReaderQuotas.MaxNameTableCharCount = 2147483647;
binding.ReaderQuotas.MaxBytesPerRead = 2147483647;
binding.MaxReceivedMessageSize = 20000000;
binding.ReaderQuotas.MaxStringContentLength = 2147483647;
binding.SendTimeout = TimeSpan.FromMinutes(10);
binding.CloseTimeout = TimeSpan.FromMinutes(10);
binding.OpenTimeout = TimeSpan.FromMinutes(10);
binding.ReceiveTimeout = TimeSpan.FromMinutes(10);
//EndpointIdentity.CreateUpnIdentity("user@domain");
ChannelFactory<IDBSyncContract> factory = new ChannelFactory<IDBSyncContract>(binding, new EndpointAddress(endPointURL));
dbProxy = factory.CreateChannel();
this.dbProxy = dbProxy as IDBSyncContract;

【问题讨论】:

  • 你引用了这个帖子stackoverflow.com/questions/884235/…
  • 我的服务器端 Web.Config security mode="None">
  • 我很困惑如何在服务器端提及属性 maxReceivedMessageSize。该属性的确切位置应该是什么。

标签: wcf wcf-binding


【解决方案1】:

客户端向服务器发送消息时是否发生错误?如果是这样,请检查以确保在您的服务器的配置文件中端点正在引用您创建的绑定:

<endpoint address="" binding="wsHttpBinding" 
 bindingConfiguration="NewBinding0" contract="IDBSyncContract" />

如果您没有通过端点元素的 bindingConfiguration 属性引用您创建的名为“NewBinding0”的绑定,WCF 将使用 WsHttpBinding 的默认值 - 在 MaxReceivedMessageSize 的情况下为 65536。

更新

在服务器端配置上设置 MaxReceivedMessageSize 值与在客户端配置上完全相同。只需在binding 元素上设置maxReceivedMessageSize 属性:

<wsHttpBinding>
  <binding name="NewBinding0" closeTimeout="00:10:00" openTimeout="00:10:00" sendTimeout="00:10:00" receiveTimeout="00:10:00" maxReceivedMessageSize="20000000"> 
    <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
    <reliableSession enabled="true" /> 
    <security mode="None">
      <transport clientCredentialType="None" /> 
      <message clientCredentialType="Windows" negotiateServiceCredential="true" establishSecurityContext="false" /> 
    </security>
  </binding>
</wsHttpBinding>

【讨论】:

  • 谢谢蒂姆,但是我在创建对象时提到了值。我有点困惑在哪里提到服务器端的属性。我尝试在 readerQuotas 和 Binding 上提到它但无济于事。
  • 下面是服务器配置文件的更多细节。
  • 客户端使用的地址是否定义在服务器的配置文件中?如果没有,我想知道您来自客户端的请求是否会发送到默认端点,该端点将使用默认的 WsHttpBinding,这可能会导致此问题。
  • 嗨,蒂姆你的意思是说我需要在基地址部分的某处提及地址“192.168.5.170/DBSyncWcfSevice/DBSyncService.svc192.168.5.161/DBSyncWcfService" /> 或在端点部分。
  • 我相信是的,是的(还没有机会使用 WCF 4.0,所以请继续阅读我所阅读的内容)。另一个选项是为您的服务定义 WsHttpBinding 的默认绑定,以便由 WCF 获取 - 但我认为最简单的方法是将“192.168.5.170/DBSyncWcfService/DBSyncService.svc”添加到端点元素的地址属性中.
猜你喜欢
  • 2014-09-13
  • 2012-05-14
  • 2011-02-23
  • 2010-11-11
  • 1970-01-01
相关资源
最近更新 更多