WCF 修改 CustomBinding 中 HttpTransportBindingElement 的 ReaderQuotas
BasicHttpBinding
类具有一个 ReaderQuotas
属性,您可以访问该属性来覆盖 MaxArrayLength
、MaxBytesPerRead
等属性。
在 CustomBinding
中使用 HttpTransportBindingElement
而不是时,如何访问 ReaderQuotas 来实现相同的效果BasicHttpBinding
?
即:
var bindingElement = new HttpTransportBindingElement();
bindingElement.MaxBufferSize = 65536; // works
bindingElement.ReaderQuotas.MaxArrayLength = 65536; // error no ReaderQuotas member
var binding = new CustomBinding(bindingElements);
binding .ReaderQuotas.MaxArrayLength = 65536; // also no ReaderQuotas member
提前感谢您的帮助。
The BasicHttpBinding
class has a ReaderQuotas
property that you can access to override attributes such as MaxArrayLength
, MaxBytesPerRead
, etc.
How can I access ReaderQuotas
to achieve the same thing when using an HttpTransportBindingElement
within a CustomBinding
instead of BasicHttpBinding
?
i.e.:
var bindingElement = new HttpTransportBindingElement();
bindingElement.MaxBufferSize = 65536; // works
bindingElement.ReaderQuotas.MaxArrayLength = 65536; // error no ReaderQuotas member
var binding = new CustomBinding(bindingElements);
binding .ReaderQuotas.MaxArrayLength = 65536; // also no ReaderQuotas member
Thanks in advance for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要使用消息编码绑定元素
TextMessageEncodingBindingElement
而不是HttpTransportBindingElement
:另一个 消息编码器类型(即二进制或MTOM)可以使用,但如果您正在进行直接转换basicHttpBinding 的默认值为文本:
You need to use the message encoding binding element
TextMessageEncodingBindingElement
notHttpTransportBindingElement
:The other message encoder types (i.e. binary or MTOM) could be used but if you are doing straight conversion the default for basicHttpBinding is text:
您可以尝试以下方法吗:
希望有帮助。
Can you try the below:
Hope that helps.