SoapCoreOptions.Binding is now obsolete

1k views Asked by At

I just updated SoapCore to version 1.1.0.22 and the project to .net 6, and i am getting a warning saying that the property Biding of SoapCoreOptions is obsolete.

The problem is: there is no clue on the property documentation of what i should use instead, and i could not find any documentation.

I need to set the binding becouse i need to change the "MaxReceivedMessageSize" and "ReaderQuotas.MaxStringContentLength", this is a port of an old project that use xml for some relative big data transfer.

What is now the "new" way of setting these values?

My Code:

//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;
            }
1

There are 1 answers

4
DeadlyChambers On

It looks like the Binding, BufferLimit and MaxStringContentLength are buried a bit. Would you mind providing your code? If you are setting up your SoapEndpoint using the IApplicationBuilder in Startup.cs Configure. Something like this

    /// <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;
            }
        });                                        }