'SoapCore - How to respond with custom HTTP status codes for certain Exceptions?
I'm using SoapCore for a SOAP web service using .NET 5. Everything works great, but I can't seem to figure out how to intercept a thrown exception in order to respond with a custom HTTP status code.
What am I missing?
What I've tried
So far, just providing a custom implementation of ISoapMessageProcessor
, registering it in Startup.cs
like this:
public void ConfigureServices(IServiceCollection services)
{
services.AddSoapCore();
services.TryAddSingleton<ISoapMessageProcessor, SoapMessageProcessor>();
...
}
But this seems to be triggered BEFORE the pipeline reaches my endpoints (and services). However, given the bulk of the exceptions I'd like to handle - by sending responses with custom HTTP Status Codes (not just 500) - are thrown from my services supporting my endpoints, this doesn't do me much good.
Is there a hook I can use that would get me access to modify the HttpResponse
AFTER it has failed in a given endpoint/service?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|