gpt4 book ai didi

c# - WCF 为 CustomBinding 中的 HttpTransportBindingElement 修改 ReaderQuotas

转载 作者:行者123 更新时间:2023-11-30 12:14:35 24 4
gpt4 key购买 nike

BasicHttpBinding 类有一个 ReaderQuotas 属性,您可以访问该属性以覆盖 MaxArrayLengthMaxBytesPerRead 等属性等

CustomBinding 而不是 BasicHttpBinding 中使用 HttpTransportBindingElement 时,如何访问 ReaderQuotas 以实现相同的目的>?

即:

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

预先感谢您的帮助。

最佳答案

您需要使用消息编码绑定(bind)元素 TextMessageEncodingBindingElement 而不是 HttpTransportBindingElement:

        var bindingElement = new TextMessageEncodingBindingElement();
bindingElement.ReaderQuotas.MaxArrayLength = 65536;

var binding = new CustomBinding();
binding.Elements.Add(bindingElement);

其他message encoder types (即二进制或 MTOM)可以使用,但如果你正在进行直接转换 the default for basicHttpBinding is text :

The value of WSMessageEncoding that indicates whether MTOM or Text/XML is used to encode SOAP messages. The default value is Text.

关于c# - WCF 为 CustomBinding 中的 HttpTransportBindingElement 修改 ReaderQuotas,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9090022/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com