我有一个WCF服务,它从数据库返回1000条记录到客户端。 我有一个ASP.NET WCF客户端(我在asp.net Web应用程序项目中添加了服务引用以使用WCF)。
运行客户端应用程序时收到以下消息:
已超出传入邮件的最大邮件大小限额(65536)。 要增加配额,请在相应的绑定元素上使用MaxReceivedMessageSize属性。
有帮助吗? 如何增加邮件大小配额?
#1楼
WCF测试客户端拥有自己的客户端配置。
运行测试客户端并滚动到底部。 如果双击“配置文件”节点,您将看到XML表示。 如您所见, maxReceivedMessageSize
为65536
。
要编辑它,请右键单击“配置文件”树节点,然后选择“使用SvcConfigEditor
编辑”。 编辑器打开时展开Bindings并双击自动生成的绑定。
您可以在此处编辑所有属性,包括maxReceivedMessageSize
。 完成后,单击文件 - 保存 。
最后,当您返回WCF测试客户端窗口时,单击工具 - 选项 。
注意 : 取消选中启动服务时始终重新生成配置 。
#2楼
我在web.config上使用此设置时出现此错误
System.ServiceModel.ServiceActivationException
我设置这样的设置:
<service name="idst.Controllers.wcf.Service_Talks">
<endpoint address="" behaviorConfiguration="idst.Controllers.wcf.Service_TalksAspNetAjaxBehavior"
binding="webHttpBinding" contract="idst.Controllers.wcf.Service_Talks" />
</service>
<service name="idst.Controllers.wcf.Service_Project">
<endpoint address="" behaviorConfiguration="idst.Controllers.wcf.Service_ProjectAspNetAjaxBehavior"
binding="basicHttpBinding" bindingConfiguration="" bindingName="largBasicHttp"
contract="idst.Controllers.wcf.Service_Project" />
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="largBasicHttp" allowCookies="true"
maxReceivedMessageSize="20000000"
maxBufferSize="20000000"
maxBufferPoolSize="20000000">
<readerQuotas maxDepth="32"
maxArrayLength="200000000"
maxStringContentLength="200000000"/>
</binding>
</basicHttpBinding>
#3楼
我在我的项目中使用CalculateRoute()在Bing Maps WPF上解决了我的问题。 我的解决方案是在“customBinding”部分的属性“httpTransport”上设置maxReceivedMessageSize和maxReceivedMessageSize。
我在applications.config文件(es.myApp.config)中设置了这个配置:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IGeocodeService" />
<binding name="BasicHttpBinding_IRouteService" />
</basicHttpBinding>
<customBinding>
<binding name="CustomBinding_IGeocodeService">
<binaryMessageEncoding />
<httpTransport manualAddressing="false" maxBufferPoolSize="524288"
maxReceivedMessageSize="2147483647" allowCookies="false" authenticationScheme="Anonymous"
bypassProxyOnLocal="false" decompressionEnabled="true" hostNameComparisonMode="StrongWildcard"
keepAliveEnabled="true" maxBufferSize="2147483647" proxyAuthenticationScheme="Anonymous"
realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
useDefaultWebProxy="true" />
</binding>
<binding name="CustomBinding_IRouteService">
<binaryMessageEncoding />
<httpTransport manualAddressing="false" maxBufferPoolSize="524288"
maxReceivedMessageSize="2147483647" allowCookies="false" authenticationScheme="Anonymous"
bypassProxyOnLocal="false" decompressionEnabled="true" hostNameComparisonMode="StrongWildcard"
keepAliveEnabled="true" maxBufferSize="2147483647" proxyAuthenticationScheme="Anonymous"
realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
useDefaultWebProxy="true" />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://dev.virtualearth.net/webservices/v1/geocodeservice/GeocodeService.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IGeocodeService"
contract="BingServices.IGeocodeService" name="BasicHttpBinding_IGeocodeService" />
<endpoint address="http://dev.virtualearth.net/webservices/v1/geocodeservice/GeocodeService.svc/binaryHttp"
binding="customBinding" bindingConfiguration="CustomBinding_IGeocodeService"
contract="BingServices.IGeocodeService" name="CustomBinding_IGeocodeService" />
<endpoint address="http://dev.virtualearth.net/webservices/v1/routeservice/routeservice.svc"
binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IRouteService"
contract="BingServices.IRouteService" name="BasicHttpBinding_IRouteService" />
<endpoint address="http://dev.virtualearth.net/webservices/v1/routeservice/routeservice.svc/binaryHttp"
binding="customBinding" bindingConfiguration="CustomBinding_IRouteService"
contract="BingServices.IRouteService" name="CustomBinding_IRouteService" />
</client>
</system.serviceModel>
#4楼
不要忘记执行入口点的app.config,而不是管理Web服务调用的类库项目中的app.config(如果有)。
例如,如果在运行单元测试时遇到错误,则需要在测试项目中设置适当的配置。
#5楼
我找到了简单的方法
---右键单击webconfig或app配置文件,然后单击EDIT WCF CONFIGURATION并选择bingdigs和选择yore服务,右侧显示maxReciveMessageSize给出一个大数字---
来源:oschina
链接:https://my.oschina.net/stackoom/blog/3161592