SilverLight调用WCF,提交的是一个List
Message=已超过传入消息(65536)的最大消息大小配额。若要增加配额,请使用相应绑定元素上的 MaxReceivedMessageSize 属性。
Source=System.ServiceModel
StackTrace:
在 System.ServiceModel.Channels.HttpInput.ThrowHttpProtocolException(String message, HttpStatusCode statusCode, String statusDescription)
费了牛劲在网上搜了一通,有的说是要修改behavior的maxItemsInObjectGraph,有的说要修改binding的maxBufferSize/maxReceivedMessageSize,有的说要增加readerQuotas,有的是endpoint没有与自定义binding配置节关联起来,有的说要客户端和服务器端都要改(我的应用中,接受数据的是服务器端,客户端负责提交,所以应该不关客户端的事儿)。。。然后把server端的配置文件调整成下面这样:
1:
2:
3:
4:"MessageHeaderOperationBehaviourAuthenticationBehavior">
5:
6:"true"/>
7:"true"/>
8:
9:
10:
11:"true" multipleSiteBindingsEnabled="true"/>
12:
13:"MessageHeaderOperationBehaviourAuthenticationBehavior"
14: name="MessageHeaderOperationBehaviourAuthentication">
15:"" binding="basicHttpBinding" ="" contract="DyeService">
16:
17:
18:
19:
20:
21:"" maxBufferSize="2147483647"
22: maxBufferPoolSize="21474836471"
23: < maxDepth="2147483647" maxStringContentLength="2147483647"
24: maxArrayLength="2147483647" maxBytesPerRead="2147483647"
25: maxNameTableCharCount="2147483647" />
26:"None" />
27:
28:
29:
30:
但是问题依旧。最后在stackoverflow找到了正解:WCF Error - unexpected response: (400) Bad Request.,里面链接到了另一篇帖子:Cannot get the MaxReceivedMessageSize higher than (65536)
解决办法就是:配置文件中,service 的name属性必须与服务的类型全名称保持一致,才能应用上自定义的配置节。
按着这个方法,调整之后的配置文件如下所示(删掉了其他无关的maxItemsInObjectGraph、readerQuotas等):
1:
2:
3:
4:
5:"MessageHeaderOperationBehaviourAuthenticationBehavior">
6:"true"/>
7:"true"/>
8:
9:
10:
11:"true" multipleSiteBindingsEnabled="true"/>
12:
13:"MessageHeaderOperationBehaviourAuthenticationBehavior"
14:
15:"" binding="basicHttpBinding" >
16:
17:
18:
19:
20:
21:"2147483647"
22: maxBufferPoolSize="21474836471" maxReceivedMessageSize="2147483647">
23:
24:
25:
26: