.net 已超过传入邮件的最大邮件大小配额(65536)
对于WCF服务,我有以下配置 即使我增加了maxReceivedMessageSize,服务仍会抛出一个错误: 已超过传入邮件的最大邮件大小配额(65536)。要增加配额,请在相应的绑定元素上使用MaxReceivedMessageSize属性。`“异常 如何解决这个问题.net 已超过传入邮件的最大邮件大小配额(65536),.net,wcf,web-services,configuration,.net,Wcf,Web Services,Configuration,对于WCF服务,我有以下配置 即使我增加了maxReceivedMessageSize,服务仍会抛出一个错误: 已超过传入邮件的最大邮件大小配额(65536)。要增加配额,请在相应的绑定元素上使用MaxReceivedMessageSize属性。`“异常 如何解决这个问题 <system.serviceModel> <services> <service name="MyService" behaviorConfiguration="MySe
<system.serviceModel>
<services>
<service name="MyService" behaviorConfiguration="MyServiceTypeBehaviors">
<endpoint address="http://localhost:22230/MyService.svc"
binding="basicHttpBinding"
bindingConfiguration="MyServiceBinding"
contract="IMyService" />
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceTypeBehaviors" >
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="MyServiceBinding"
hostNameComparisonMode="StrongWildcard"
receiveTimeout="00:10:00"
sendTimeout="00:10:00"
openTimeout="00:10:00"
closeTimeout="00:10:00"
maxReceivedMessageSize="6553600"
maxBufferSize="6553600"
maxBufferPoolSize="524288"
transferMode="Buffered"
messageEncoding="Text"
textEncoding="utf-8"
bypassProxyOnLocal="false"
useDefaultWebProxy="true" >
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel
如果这是服务配置,您应该查看客户端配置,并将maxReceivedMessageSize与服务器消息大小匹配。消息来自您的客户端。您需要增加客户端配置中的最大消息大小。默认值为65536,加倍可能足以满足您的需要
如果以编程方式配置端点,以下代码段可能会有所帮助:
BasicHttpBinding binding = new BasicHttpBinding() { MaxReceivedMessageSize = 131072 };
然后,在实例化服务客户端时,将此绑定对象传递给构造函数。例如:
MyServiceClient client = new MyServiceClient(binding, "http://www.mysite.com/MyService/");
确保你复制了新的App.config我的理论是你的客户端配置没有正确配置。你是说,这是正确的,应该可以工作吗?我的客户端现在是WCFTestClient。中有一些想法,其中一些不适用(例如,你已经增加了maxBufferSize),但可能值得更仔细地查看。然后您必须更改WCFTestClient的配置(转到工具和选项)或向WCFTestClient发送较少的数据。要更改wcf测试客户端的配置(在我的情况下为FW 4.0),您应该右键单击左侧文件列表树中最低的配置文件。选择“使用SvcConfigEditor编辑“然后选择绑定。在绑定元素中找到此处标记的3个成员。将其设置为2MB作为合理大小。