如何设置 .NET 客户端 Web 服务 ClientRuntime.MaxFaultSize
我正在调用一个 java web 服务,该服务返回包含错误列表的FaultException 类型。所以响应消息的大小总是很大。
在我的 C# (clr3.5) 客户端中,我收到以下错误
“已超出传入消息的最大消息大小配额 (65536)。要增加配额,请在相应的绑定元素上使用 MaxReceivedMessageSize 属性。”
我相信解决此问题的方法是设置 ClientRuntime.MaxFaultSize
msdn-doc
有没有办法在 app.config 中执行此操作?
I'm calling a java webservice that returns a type of FaultException that contains a list of errors. So the response message size is always large.
In my c# (clr3.5) client I get the following 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 believe the fix for this is to set the ClientRuntime.MaxFaultSize
msdn-doc
Is there a way to do this in the app.config ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须设置 ClientRuntime.MaxFaultSize 属性,请参阅此处< /a>
a) 应用于 ChannelFactory:
b) 或生成的代理:
You must set ClientRuntime.MaxFaultSize property, see here
a) to ChannelFactory:
b) or to generated proxy:
当我们遇到这个问题时,我们按照错误消息更改了 app.config 的绑定配置中的 MaxReceivedMessageSize 属性。这不适合你吗?
编辑:如果仍然不起作用,我发现 这篇文章。它建议创建合同行为属性。虽然示例将限制编码到属性构造函数中,但您可以从自己的配置值中提取。还没有看到直接的 .NET 配置,但我会查看行为配置。
When we ran into this problem, we followed the error message and changed the MaxReceivedMessageSize property in the bindings configuration of our app.config. Is this not working for you?
EDIT: If that still doesn't work, I found this post. It suggests creating a Contract Behavior attribute. While the example codes the limit into the attribute constructor, you could pull from your own configuration value. Haven't seen a straight .NET configuration yet, but I'd look in behavior configuration.