gpt4 book ai didi

c# - SoapCoreOptions.Binding 现已过时

转载 作者:行者123 更新时间:2023-12-05 05:51:36 25 4
gpt4 key购买 nike

我刚刚将 SoapCore 更新到版本 1.1.0.22 并将项目更新到 .net 6,我收到一条警告,指出 SoapCoreOptions 的属性 Biding 已过时。

问题是:关于我应该使用什么的属性文档没有任何线索,而且我找不到任何文档。

我需要设置绑定(bind),因为我需要更改“MaxReceivedMessageSize”和“ReaderQuotas.MaxStringContentLength”,这是使用 xml 进行一些相关大数据传输的旧项目的端口。

现在设置这些值的"new"方法是什么?

我的代码:

//builder is IApplicationBuilder
builder.UseEndpoints(endpoints =>
{
endpoints.UseSoapEndpoint<IMyService>(options =>
{
options.Path = "URL.asmx";
options.Binding = AumentarTamanhoString(Lint_TamanhoMaximoRequisicao);
options.CaseInsensitivePath = true;

});

endpoints.UseSoapEndpoint<IMyService2>(options =>
{
options.Path = "URL2.asmx";
options.Binding = AumentarTamanhoString(Lint_TamanhoMaximoRequisicao);
options.CaseInsensitivePath = true;

});
});


static BasicHttpBinding AumentarTamanhoString(int Pint_TamanhoMaximoRequisicao)
{
BasicHttpBinding Lobj_Retorno = new()
{
MaxReceivedMessageSize = (long)Pint_TamanhoMaximoRequisicao,
};
Lobj_Retorno.ReaderQuotas.MaxStringContentLength = Pint_TamanhoMaximoRequisicao;
return Lobj_Retorno;
}

最佳答案

看起来 Binding、BufferLimit 和 MaxStringContentLength 被隐藏了一点。你介意提供你的代码吗?如果您使用 Startup.cs Configure 中的 IApplicationBuilder 设置 SoapEndpoint。像这样

    /// <summary>
/// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
/// </summary>
/// <param name="app"></param>
/// <param name="env"></param>
/// <param name="loggerFactory"></param>
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseSoapEndpoint<IMyService>(soap =>
{
soap.Binding = new BasicHttpBinding(BasicHttpSecurityMode.None);
soap.Path = "/Service.svc";
soap.SoapSerializer = SoapSerializer.DataContractSerializer;
soap.BufferLimit = int.MaxValue;
soap.UseBasicAuthentication = true;
foreach(var encoder in soap.EncoderOptions)
{
encoder.BindingName = "Basic";
encoder.ReaderQuotas.MaxStringContentLength = int.MaxValue;
}
}); }

关于c# - SoapCoreOptions.Binding 现已过时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70354495/

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