在 web.config 中更改时,WCF MaxReceivedMessageSize 将不会更新
我在网上浏览了一下,这个问题的解决方案似乎都不适合我。我有一个由 Silverlight 应用程序使用的 WCF 服务。一切正常,直到我尝试更新大型对象图。我的跟踪日志向我展示了一个可爱的错误:
传入消息的最大消息大小配额 (65536) 已调整为 超过了。要增加配额,请使用 MaxReceivedMessageSize 适当的绑定元素上的属性。
我已经更改了 web.config 文件和 Silverlight 的 ClientConfig 文件中的设置,甚至尝试手动创建代理并在代码中设置值。
我的 web.config:
<system.serviceModel>
<diagnostics>
<messageLogging logMalformedMessages="true" logMessagesAtTransportLevel="true" />
<endToEndTracing propagateActivity="true" activityTracing="true"
messageFlowTracing="true" />
</diagnostics>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBindingSettings" closeTimeout="00:10:00" openTimeout="00:10:00" sendTimeout="00:10:00"
maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" messageEncoding="Text">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="TestConfigService">
<endpoint address="" contract="PreferencesUI.Hub.PreferenceSVC.ITestConfig" binding="basicHttpBinding"
bindingConfiguration="basicHttpBindingSettings" />
</service>
</services>
</system.serviceModel>
我的 Silverlight:
EndpointAddress ea = new EndpointAddress("http://localhost:37935/TestConfig.svc");
BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.None);
binding.CloseTimeout = new TimeSpan(00, 5, 00);
binding.OpenTimeout = new TimeSpan(00, 5, 00);
binding.ReceiveTimeout = new TimeSpan(00, 5, 00);
binding.SendTimeout = new TimeSpan(00, 5, 00);
binding.TextEncoding = System.Text.Encoding.UTF8;
binding.MaxReceivedMessageSize = int.MaxValue;
binding.MaxBufferSize = int.MaxValue;
_preferenceTSTServiceProxy = new TSTC.TestConfigClient(binding, ea);
有人看到我在这里错过了什么吗?我在网上找到的所有内容都表明有人忘记设置 maxReceivedMessageSize 或忘记为端点提供绑定配置名称值(这两者我都完成了)。
I've looked around on the web and none of the solutions to this problem seem to work for me. I have a WCF service being consumed by a Silverlight application. Everything works fine until I attempt to update a large object graph. My trace logs greet me with the lovely error:
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.
I've changed the setting in both my web.config file and in the Silverlight's ClientConfig file and even tried manually creating the proxy and setting the value in code.
My web.config:
<system.serviceModel>
<diagnostics>
<messageLogging logMalformedMessages="true" logMessagesAtTransportLevel="true" />
<endToEndTracing propagateActivity="true" activityTracing="true"
messageFlowTracing="true" />
</diagnostics>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBindingSettings" closeTimeout="00:10:00" openTimeout="00:10:00" sendTimeout="00:10:00"
maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" messageEncoding="Text">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="TestConfigService">
<endpoint address="" contract="PreferencesUI.Hub.PreferenceSVC.ITestConfig" binding="basicHttpBinding"
bindingConfiguration="basicHttpBindingSettings" />
</service>
</services>
</system.serviceModel>
My Silverlight:
EndpointAddress ea = new EndpointAddress("http://localhost:37935/TestConfig.svc");
BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.None);
binding.CloseTimeout = new TimeSpan(00, 5, 00);
binding.OpenTimeout = new TimeSpan(00, 5, 00);
binding.ReceiveTimeout = new TimeSpan(00, 5, 00);
binding.SendTimeout = new TimeSpan(00, 5, 00);
binding.TextEncoding = System.Text.Encoding.UTF8;
binding.MaxReceivedMessageSize = int.MaxValue;
binding.MaxBufferSize = int.MaxValue;
_preferenceTSTServiceProxy = new TSTC.TestConfigClient(binding, ea);
Does anyone see what I've missed here? Everything I find on the web points out that someone forgot to either set maxReceivedMessageSize or forgot to give the endpoint a bindingConfiguration name value (both of which I've done).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
呃。我讨厌 WCF 的这一特定方面。它的理解过于复杂,而且很难正确理解。
我并不声称理解这一切,但我知道除了正确的绑定之外,还有其他地方可以设置“MaxReceivedMessageSize”属性。还可以尝试底层传输,如下所示:
或者像这样:
并且可能还有其他地方。
Uggh. I hate this particular aspect of WCF. It's unnecessarily complex to understand, and hard to get right.
I don't claim to understand it all, but I know that there are other places where the "MaxReceivedMessageSize" property can be set, in addition to the binding proper. Also try the underlying transport, like so:
Or like this:
And there may be other places as well.