【问题标题】:WCF Service Error - Maximum message size quota for incoming messages (65536) has been exceededWCF 服务错误 - 已超出传入消息 (65536) 的最大消息大小配额
【发布时间】:2014-02-01 20:01:23
【问题描述】:

全部,

我有一个 WCF 服务(在 asp.net 4.0 Web 应用程序中),在 asp.net 兼容模式下运行。 当我的 silverlight 客户端向服务 Save(SomeLargeObject) 发布大量数据时,我从服务器收到此消息(400-Bad Request)。我在服务器上跟踪了错误并从服务中得到了这个:

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

为了解决这个错误,我更新了我的服务器服务配置文件 (web.config):

<bindings>
      <basicHttpBinding>
        <binding name="WebStoreServices_BasicHttpBinding" maxBufferSize="2147483647"
          maxReceivedMessageSize="2147483647">
          <security mode="None" />
        </binding>
      </basicHttpBinding>
      <wsHttpBinding>
        <binding name="MyBinding" maxReceivedMessageSize="2147483647" />
      </wsHttpBinding>
      <webHttpBinding>
        <binding name="NewBinding0" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" />
      </webHttpBinding>
    </bindings>

和我的 Silverlight 客户端服务配置文件:

<system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IWebStoreServices" maxBufferSize="2147483647"
                    maxReceivedMessageSize="2147483647">
                    <security mode="None" />
                </binding>
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://localhost:1271/Services/WebStoreServices.svc"
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IWebStoreServices"
                contract="WebStore.IWebStoreServices" name="BasicHttpBinding_IWebStoreServices" />
        </client>
    </system.serviceModel>

我仍然在服务器上收到上述错误,“传入消息的最大消息大小配额(65536)”,就像我在服务器上的绑定被忽略了。为什么它忽略了我的设置!我确实使用 WCF 工具来创建绑定以避免错误。

【问题讨论】:

  • 您能否至少展示一个服务配置示例(例如,在 元素中声明一个服务端点)
  • 问题已解决,感谢您的帮助。是的,我的 system.service 模型只有绑定。

标签: asp.net wcf silverlight wcf-binding


【解决方案1】:

设置看起来不错 - 但是使用 basicHttpBinding 的服务器端端点实际上引用该绑定配置与增加的 MaxReceivedMessageSize 设置完全没有关系?

您应该在服务器端 web.config 中进行类似的设置:

<services>
   <service name="WebStore.WebStoreServices">
       <!-- this endpoint uses basicHttpBinding and uses the binding configuration -->
       <endpoint name="basicHttp"
           address="......"
           binding="basicHttpBinding"
           bindingConfiguration="WebStoreServices_BasicHttpBinding" 
           contract="WebStore.IWebStoreServices" />
   </service>
</services>

如果您的 basicHttpBinding 端点缺少 bindingConfiguration="..." 设置 - 好吧,那么您已经定义了绑定配置,但您实际上并没有使用它!

【讨论】:

  • 感谢修复,它现在可以工作了,我的问题是除了 web.config 中的绑定之外我没有定义任何其他内容。这是我的第一个 WCF 服务,我认为它会以某种方式将绑定与我的编码服务相关联,而无需任何额外的配置条目。
猜你喜欢
  • 2013-11-03
  • 2014-10-23
  • 1970-01-01
  • 2020-03-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-06-24
  • 1970-01-01
相关资源
最近更新 更多