From 6ebc7787b2a441130e51cde6f197b05d94b0234d Mon Sep 17 00:00:00 2001 From: avoronin Date: Mon, 7 Oct 2024 21:12:29 +0500 Subject: [PATCH] Remove extra scope while getting IMessageInspector2. fix: #1088 --- src/SoapCore/SoapEndpointMiddleware.cs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/SoapCore/SoapEndpointMiddleware.cs b/src/SoapCore/SoapEndpointMiddleware.cs index 8347f78f..2b01160b 100644 --- a/src/SoapCore/SoapEndpointMiddleware.cs +++ b/src/SoapCore/SoapEndpointMiddleware.cs @@ -495,16 +495,10 @@ private async Task ProcessMessage(Message requestMessage, SoapMessageEn throw new ArgumentException($"Unable to handle request without a valid action parameter. Please supply a valid soap action."); } + var messageInspector2s = serviceProvider.GetServices(); var correlationObjects2 = default(List<(IMessageInspector2 inspector, object correlationObject)>); - //Not sure that this extra scope is needed... - using (IServiceScope scope = serviceProvider.CreateScope()) - { - var messageInspector2s = scope.ServiceProvider.GetServices(); - correlationObjects2 = messageInspector2s.Select(mi => - (inspector: mi, correlationObject: mi.AfterReceiveRequest(ref requestMessage, _service))) - .ToList(); - } + correlationObjects2 = messageInspector2s.Select(mi => (inspector: mi, correlationObject: mi.AfterReceiveRequest(ref requestMessage, _service))).ToList(); // for getting soapaction and parameters in (optional) body // GetReaderAtBodyContents must not be called twice in one request