asp.net-core - 如何增加 ASP.Net Core SOAP ServiceContract 中的字节限制?
问题描述
我有一个与 Quickbooks Web 连接器通信的 ASP.Net Core 3 应用程序。
我无法弄清楚如何将允许的最大字节数从 8192 增加到更大的值。大多数 Quickbooks 请求包含比这更多的数据。
我的服务合同中有以下内容:
QBWC.asmx
[ServiceContract(Namespace = @"http://developer.intuit.com/")]
public interface IQBWCService
{
[OperationContract]
int receiveResponseXML(string ticket, string response, string hresult, string message);
}
在我的 Startup.cs
app.UseSoapEndpoint<IQBWCService>("/qbwc/qbwc.asmx", new BasicHttpBinding(), SoapSerializer.XmlSerializer, true);
当 Quickbooks 尝试发送大于 8192 字节的任何内容时,我收到以下错误:
System.Xml.XmlException: The maximum string content length quota (8192) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader.
我在任何地方都找不到任何名为 MaxStringContentLength 的东西。
对我做错了什么有帮助吗?
解决方案
想通了。更改此行
app.UseSoapEndpoint<IQBWCService>("/qbwc/qbwc.asmx", new BasicHttpBinding(), SoapSerializer.XmlSerializer, true);
对此
var httpBinding = new BasicHttpBinding();
httpBinding.ReaderQuotas.MaxStringContentLength = 5000000;
app.UseSoapEndpoint<IQBWCService>("/qbwc/qbwc.asmx", httpBinding, SoapSerializer.XmlSerializer, true);
推荐阅读
- c++ - 如何在 xstring 中处理此异常?
- java - 如何在java中调用泛型类型的方法?
- qt - QTextTable中的交替行背景
- php - 项目缺少默认错误模板 Symfony
- vb.net - 消息框和运行时错误窗口如何在 VB .NET 中本地化?
- delphi - 如何将枚举类型作为方法的参数传递?
- android - 微调器上的自定义 ArrayAdapter 显示微调器外部的自定义布局图像
- c# - WPF 将鼠标滚轮事件从 ContextMenu 发送到 Window
- asp.net-core-mvc - jsreport.AspNetCore mvc 页面到 PDF 正确呈现 Intranet 但在远程站点使用时大小不同
- c - while 循环内的表达式求值