【发布时间】:2011-09-23 04:20:09
【问题描述】:
我有一个单元测试将一个中等大小的对象发送到 WCF 服务。如果我为该参数传递 null,则一切正常。当我发送一个填充对象时,我得到一个 HTTP 400 响应。
WCF 跟踪显示此错误:
传入邮件的最大邮件大小配额 (65536) 已达到 超过了。
但是,我在 app.config 中为单元测试项目设置了大小配置参数,如下所示:
<basicHttpBinding>
<binding name="BasicHttpBinding_IMyAppService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="200000000" maxBufferPoolSize="200000000" maxReceivedMessageSize="200000000"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxArrayLength="200000000" maxStringContentLength="200000000"/>
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
我的配置中缺少什么以将允许的消息大小提高到错误消息中看到的 65536 以上?
更新:
Web 服务主机的 web.config 文件还将 maxReceivedMessageSize 设置为一个较大的值(我认为):
<binding name="basicHttpBindingConfig" maxReceivedMessageSize="20000000" maxBufferSize="20000000" maxBufferPoolSize="20000000">
<readerQuotas maxDepth="32" maxArrayLength="200000000" maxStringContentLength="200000000"/>
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm"/>
</security>
</binding>
【问题讨论】:
标签: wcf-binding