WCF - 如何增加消息大小配额 [英] WCF - How to Increase Message Size Quota

查看:28
本文介绍了WCF - 如何增加消息大小配额的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 WCF 服务,它从数据库向客户端返回 1000 条记录.我有一个 ASP.NET WCF 客户端(我在 asp.net web 应用程序项目中添加了服务引用以使用 WCF).

I have a WCF Service which returns 1000 records from database to the client. I have an ASP.NET WCF client (I have added service reference in asp.net web application project to consume WCF).

我在运行客户端应用程序时收到以下消息:

I get the following message when I run the client application:

传入消息的最大消息大小配额 (65536) 已达到超过了.要增加配额,请使用MaxReceivedMessageSize 属性适当的绑定元素.

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.

有什么帮助吗?如何增加邮件大小配额?

Any help? How to increase message size quota?

推荐答案

你会想要在 App.configWeb.config 中增加这样的东西来增加消息大小配额 文件:

You'll want something like this to increase the message size quotas, in the App.config or Web.config file:

<bindings>
    <basicHttpBinding>
        <binding name="basicHttp" allowCookies="true"
                 maxReceivedMessageSize="20000000" 
                 maxBufferSize="20000000"
                 maxBufferPoolSize="20000000">
            <readerQuotas maxDepth="32" 
                 maxArrayLength="200000000"
                 maxStringContentLength="200000000"/>
        </binding>
    </basicHttpBinding>
</bindings>

并在端点配置中使用绑定名称,例如

And use the binding name in your endpoint configuration e.g.

...
bindingConfiguration="basicHttp"
...

这些值的理由很简单,它们足够大以容纳大多数消息.您可以调整该数字以满足您的需要.低默认值基本上是为了防止 DOS 类型的攻击.将其设为 20000000 将允许分布式 DOS 攻击有效,默认大小 64k 将需要非常大量的客户端来压倒如今的大多数服务器.

The justification for the values is simple, they are sufficiently large to accommodate most messages. You can tune that number to fit your needs. The low default value is basically there to prevent DOS type attacks. Making it 20000000 would allow for a distributed DOS attack to be effective, the default size of 64k would require a very large number of clients to overpower most servers these days.

这篇关于WCF - 如何增加消息大小配额的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆