Programatically add/remove SOAP core endpoints in Kestrel

579 Views Asked by At

I am creating a web host that uses SOAPCore for the middleware. Once I build the web host, I am unsure if it is possible to add in new SOAPCore endpoints for specific paths.

Here is how I build the web host:

var webHost = new WebHostBuilder().UseKestrel(x => x.AllowSynchronousIO = true).UseUrls($"http://*:8381").UseStartup<StartupClass>().ConfigureLogging(x =>
    {
        x.SetMinimumLevel(LogLevel.Trace);
        x.AddDebug();
        x.AddConsole();
    }).Build()

Here is the configure method in the StartupClass

public void Configure(IApplicationBuilder app)
    {
        app.UseSoapEndpoint<SoapInterface1>(options =>
            {
                options.Path = "/path1";
                options.UseBasicAuthentication = false;
                options.EncoderOptions = new[]
                {
                    new SoapEncoderOptions
                    {
                        MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap12, AddressingVersion.None),
                        WriteEncoding = Encoding.UTF8,
                        ReaderQuotas = XmlDictionaryReaderQuotas.Max,
                    }
                };
                options.SoapSerializer = SoapSerializer.XmlSerializer;
                options.CaseInsensitivePath = true;
                options.IndentXml = false;
                options.OmitXmlDeclaration = true;
            });
    }

I have found https://gist.github.com/Tratcher/ae23d9a7b4c8c7c37d7a769ad68bd228 that shows how to add and remove ports using the kestrel config. I am wondering if there is something similar (or better) that will allow me to programmatically add in the SOAP endpoints?

Specifically, adding in something like this after the web host is built (they may or may not use the same interface):

app.UseSoapEndpoint<SoapInterface2>(options =>
            {
                options.Path = "/path2";
                options.UseBasicAuthentication = false;
                options.EncoderOptions = new[]
                {
                    new SoapEncoderOptions
                    {
                        MessageVersion = MessageVersion.CreateVersion(EnvelopeVersion.Soap12, AddressingVersion.None),
                        WriteEncoding = Encoding.UTF8,
                        ReaderQuotas = XmlDictionaryReaderQuotas.Max,
                    }
                };
                options.SoapSerializer = SoapSerializer.XmlSerializer;
                options.CaseInsensitivePath = true;
                options.IndentXml = false;
                options.OmitXmlDeclaration = true;
            });

Any help would be greatly appreciated.

0

There are 0 best solutions below