diff --git a/src/SoapCore.Benchmark/SoapCore.Benchmark.csproj b/src/SoapCore.Benchmark/SoapCore.Benchmark.csproj index 8b90237b..dbcaf804 100644 --- a/src/SoapCore.Benchmark/SoapCore.Benchmark.csproj +++ b/src/SoapCore.Benchmark/SoapCore.Benchmark.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.1;net5.0;net6.0 + netcoreapp3.1;net8.0 ..\SoapCore.ruleset true 8 @@ -12,13 +12,8 @@ - - - - - - - + + diff --git a/src/SoapCore.Tests/MessageInspector/ClientMessageInspector.cs b/src/SoapCore.Tests/MessageInspector/ClientMessageInspector.cs deleted file mode 100644 index 1809e1d4..00000000 --- a/src/SoapCore.Tests/MessageInspector/ClientMessageInspector.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ServiceModel; -using System.ServiceModel.Channels; -using System.ServiceModel.Dispatcher; - -namespace SoapCore.Tests.MessageInspector -{ - [Obsolete] - public class ClientMessageInspector : IClientMessageInspector - { - private readonly Dictionary _customHeaders; - - public ClientMessageInspector(Dictionary customHeaders) - { - _customHeaders = customHeaders; - } - - public void AfterReceiveReply(ref Message reply, object correlationState) - { - } - - public object BeforeSendRequest(ref Message request, IClientChannel channel) - { - foreach (var kvp in _customHeaders) - { - var header = MessageHeader.CreateHeader(kvp.Key, "SoapCore", kvp.Value); - request.Headers.Add(header); - } - - return Guid.NewGuid(); - } - } -} diff --git a/src/SoapCore.Tests/MessageInspector/CustomHeadersEndpointBehavior.cs b/src/SoapCore.Tests/MessageInspector/CustomHeadersEndpointBehavior.cs deleted file mode 100644 index d6628120..00000000 --- a/src/SoapCore.Tests/MessageInspector/CustomHeadersEndpointBehavior.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ServiceModel.Channels; -using System.ServiceModel.Description; -using System.ServiceModel.Dispatcher; - -namespace SoapCore.Tests.MessageInspector -{ - [Obsolete] - public class CustomHeadersEndpointBehavior : IEndpointBehavior - { - private Dictionary _customHeaders; - - public CustomHeadersEndpointBehavior(Dictionary customHeaders) - { - _customHeaders = customHeaders; - } - - public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime) - { - clientRuntime.ClientMessageInspectors.Add(new ClientMessageInspector(_customHeaders)); - } - - public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters) - { - } - - public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher) - { - } - - public void Validate(ServiceEndpoint endpoint) - { - } - } -} diff --git a/src/SoapCore.Tests/MessageInspector/MessageInspectorMock.cs b/src/SoapCore.Tests/MessageInspector/MessageInspectorMock.cs deleted file mode 100644 index d609e538..00000000 --- a/src/SoapCore.Tests/MessageInspector/MessageInspectorMock.cs +++ /dev/null @@ -1,91 +0,0 @@ -using System; -using System.IO; -using System.ServiceModel.Channels; -using System.Xml; -using SoapCore.Extensibility; - -namespace SoapCore.Tests.MessageInspector -{ - [Obsolete] - public class MessageInspectorMock : IMessageInspector - { - public static bool AfterReceivedRequestCalled { get; private set; } - public static bool BeforeSendReplyCalled { get; private set; } - public static string Action { get; private set; } - public static Message LastReceivedMessage { get; private set; } - - public static void Reset() - { - LastReceivedMessage = null; - AfterReceivedRequestCalled = false; - BeforeSendReplyCalled = false; - Action = null; - } - - public object AfterReceiveRequest(ref Message message) - { - if (message == null) - { - throw new System.ArgumentNullException(nameof(message)); - } - - LastReceivedMessage = message; - AfterReceivedRequestCalled = true; - Action = message.Headers.Action; - - using (var buffer = message.CreateBufferedCopy(int.MaxValue)) - { - CorrelationStateMessage state; - using (var stringWriter = new StringWriter()) - { - using (var xmlTextWriter = new XmlTextWriter(stringWriter)) - { - buffer.CreateMessage().WriteMessage(xmlTextWriter); - xmlTextWriter.Flush(); - xmlTextWriter.Close(); - - state = new CorrelationStateMessage - { - InternalUID = "Foo", - Message = stringWriter.ToString() - }; - } - } - - // Assign an new message because body can be read only once... - message = buffer.CreateMessage(); - - return state; - } - } - - public void BeforeSendReply(ref Message reply, object correlationState) - { - if (reply == null) - { - throw new System.ArgumentNullException(nameof(reply)); - } - - if (correlationState == null) - { - throw new System.ArgumentNullException(nameof(correlationState)); - } - - if (correlationState is CorrelationStateMessage state) - { - if (state.InternalUID != "Foo") - { - throw new System.Exception("InternalUID not correct"); - } - } - - BeforeSendReplyCalled = true; - } - - internal class CorrelationStateMessage - { - internal string InternalUID { get; set; } - internal string Message { get; set; } - } - } -} diff --git a/src/SoapCore.Tests/MessageInspector/MessageInspectorTests.cs b/src/SoapCore.Tests/MessageInspector/MessageInspectorTests.cs deleted file mode 100644 index 60a6544d..00000000 --- a/src/SoapCore.Tests/MessageInspector/MessageInspectorTests.cs +++ /dev/null @@ -1,149 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.ServiceModel; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Hosting.Server.Features; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using SoapCore.Tests.Model; - -namespace SoapCore.Tests.MessageInspector -{ - [Obsolete] - [TestClass] - public class MessageInspectorTests - { - private static IWebHost _host; - - [ClassInitialize] - public static void StartServer(TestContext testContext) - { - _host = new WebHostBuilder() - .UseKestrel() - .UseUrls("http://127.0.0.1:0") - .UseStartup() - .Build(); - - var task = _host.RunAsync(); - - while (true) - { - if (_host != null) - { - if (task.IsFaulted && task.Exception != null) - { - throw task.Exception; - } - - if (!task.IsCompleted || !task.IsCanceled) - { - if (!_host.ServerFeatures.Get().Addresses.First().EndsWith(":0")) - { - break; - } - } - } - - Thread.Sleep(2000); - } - } - - [ClassCleanup] - public static async Task StopServer() - { - await _host.StopAsync(); - } - - [TestInitialize] - public void Reset() - { - MessageInspectorMock.Reset(); - } - - public ITestService CreateClient(Dictionary headers = null) - { - var addresses = _host.ServerFeatures.Get(); - var address = addresses.Addresses.Single(); - - var binding = new BasicHttpBinding(); - var endpoint = new EndpointAddress(new Uri(string.Format("{0}/Service.svc", address))); - var channelFactory = new ChannelFactory(binding, endpoint); - channelFactory.Endpoint.EndpointBehaviors.Add(new CustomHeadersEndpointBehavior(headers)); - var serviceClient = channelFactory.CreateChannel(); - return serviceClient; - } - - [TestMethod] - public void AfterReceivedRequestCalled() - { - Assert.IsFalse(MessageInspectorMock.AfterReceivedRequestCalled); - var client = CreateClient(new Dictionary() { { "header1-key", "header1-value" } }); - var result = client.Ping("hello, world"); - Assert.IsTrue(MessageInspectorMock.AfterReceivedRequestCalled); - } - - [TestMethod] - public void AfterReceivedRequestHasAction() - { - Assert.IsNull(MessageInspectorMock.Action); - var client = CreateClient(new Dictionary() { { "header1-key", "header1-value" } }); - var result = client.Ping("hello, world"); - Assert.IsNotNull(MessageInspectorMock.Action); - } - - [TestMethod] - public void BeforeSendReplyCalled() - { - Assert.IsFalse(MessageInspectorMock.BeforeSendReplyCalled); - var client = CreateClient(new Dictionary() { { "header1-key", "header1-value" } }); - var result = client.Ping("hello, world"); - Assert.IsTrue(MessageInspectorMock.BeforeSendReplyCalled); - } - - [TestMethod] - public void SingleSoapHeader() - { - var client = CreateClient(new Dictionary() { { "header1-key", "header1-value" } }); - var result = client.Ping("hello, world"); - var msg = MessageInspectorMock.LastReceivedMessage; - var index = msg.Headers.FindHeader("header1-key", "SoapCore"); - Assert.AreEqual(msg.Headers.GetHeader(index), "header1-value"); - } - - [TestMethod] - public void MultipleSoapHeaders() - { - var client = CreateClient(new Dictionary() { { "header1-key", "header1-value" }, { "header2-key", 2 } }); - var result = client.Ping("hello, world"); - var msg = MessageInspectorMock.LastReceivedMessage; - Assert.AreEqual(msg.Headers.GetHeader(msg.Headers.FindHeader("header1-key", "SoapCore")), "header1-value"); - Assert.AreEqual(msg.Headers.GetHeader(msg.Headers.FindHeader("header2-key", "SoapCore")), 2); - } - - [TestMethod] - public void ComplexSoapHeader() - { - var client = CreateClient(new Dictionary() - { - { - "complex", new ComplexModelInput() - { - StringProperty = "hello, world", - IntProperty = 1000, - ListProperty = new List { "test", "list", "of", "strings" }, - DateTimeOffsetProperty = new DateTimeOffset(2018, 12, 31, 13, 59, 59, TimeSpan.FromHours(1)) - } - } - }); - - var result = client.Ping(string.Empty); - var msg = MessageInspectorMock.LastReceivedMessage; - var complex = msg.Headers.GetHeader(msg.Headers.FindHeader("complex", "SoapCore")); - Assert.AreEqual(complex.StringProperty, "hello, world"); - Assert.AreEqual(complex.IntProperty, 1000); - CollectionAssert.AreEqual(complex.ListProperty, new List { "test", "list", "of", "strings" }); - } - } -} diff --git a/src/SoapCore.Tests/MessageInspector/Startup.cs b/src/SoapCore.Tests/MessageInspector/Startup.cs deleted file mode 100644 index 36b7baad..00000000 --- a/src/SoapCore.Tests/MessageInspector/Startup.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using System.ServiceModel; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.DependencyInjection.Extensions; -using Microsoft.Extensions.Logging; - -namespace SoapCore.Tests.MessageInspector -{ - [Obsolete] - public class Startup - { - public void ConfigureServices(IServiceCollection services) - { - services.AddSoapCore(); - services.TryAddSingleton(); - services.AddSoapMessageInspector(new MessageInspectorMock()); - services.AddMvc(); - } - -#if !NETCOREAPP3_0_OR_GREATER - public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) - { - app.UseSoapEndpoint("/Service.svc", new SoapEncoderOptions(), SoapSerializer.DataContractSerializer); - app.UseMvc(); - } -#else - public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) - { - app.UseRouting(); - - app.UseEndpoints(x => - { - x.UseSoapEndpoint("/Service.svc", new SoapEncoderOptions(), SoapSerializer.DataContractSerializer); - }); - } -#endif - } -} diff --git a/src/SoapCore.Tests/MessageInspectors/InspectorStyle.cs b/src/SoapCore.Tests/MessageInspectors/InspectorStyle.cs deleted file mode 100644 index d00f4554..00000000 --- a/src/SoapCore.Tests/MessageInspectors/InspectorStyle.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace SoapCore.Tests.MessageInspectors -{ - public enum InspectorStyle - { - MessageInspector, - MessageInspector2 - } -} diff --git a/src/SoapCore.Tests/MessageInspectors/MessageInspector/MessageInspectorMock.cs b/src/SoapCore.Tests/MessageInspectors/MessageInspector/MessageInspectorMock.cs deleted file mode 100644 index 316e1a1e..00000000 --- a/src/SoapCore.Tests/MessageInspectors/MessageInspector/MessageInspectorMock.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using System.ServiceModel; -using System.ServiceModel.Channels; -using SoapCore.Extensibility; - -namespace SoapCore.Tests.MessageInspectors.MessageInspector -{ - [Obsolete] - public class MessageInspectorMock : IMessageInspector - { - public static bool AfterReceivedRequestCalled { get; private set; } - public static bool BeforeSendReplyCalled { get; private set; } - public static Message LastReceivedMessage { get; private set; } - - public static void Reset() - { - LastReceivedMessage = null; - AfterReceivedRequestCalled = false; - BeforeSendReplyCalled = false; - } - - public object AfterReceiveRequest(ref Message message) - { - LastReceivedMessage = message; - AfterReceivedRequestCalled = true; - - // Validate Message - ValidateMessage(ref message); - - return null; - } - - public void BeforeSendReply(ref Message reply, object correlationState) - { - BeforeSendReplyCalled = true; - } - - private void ValidateMessage(ref Message message) - { - throw new FaultException(new FaultReason("Message is invalid."), new FaultCode("Sender"), null); - } - } -} diff --git a/src/SoapCore.Tests/MessageInspectors/MessageInspector/MessageInspectorTests.cs b/src/SoapCore.Tests/MessageInspectors/MessageInspector/MessageInspectorTests.cs deleted file mode 100644 index 4dbaa1c5..00000000 --- a/src/SoapCore.Tests/MessageInspectors/MessageInspector/MessageInspectorTests.cs +++ /dev/null @@ -1,103 +0,0 @@ -using System; -using System.Linq; -using System.ServiceModel; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Hosting.Server.Features; -using Microsoft.VisualStudio.TestTools.UnitTesting; - -namespace SoapCore.Tests.MessageInspectors.MessageInspector -{ - [Obsolete] - [TestClass] - public class MessageInspectorTests - { - private static IWebHost _host; - - [ClassInitialize] - public static void StartServer(TestContext testContext) - { - _host = new WebHostBuilder() - .UseKestrel() - .UseUrls("http://127.0.0.1:0") - .UseStartup() - .UseSetting("InspectorStyle", InspectorStyle.MessageInspector.ToString()) - .Build(); - - var task = _host.RunAsync(); - - while (true) - { - if (_host != null) - { - if (task.IsFaulted && task.Exception != null) - { - throw task.Exception; - } - - if (!task.IsCompleted || !task.IsCanceled) - { - if (!_host.ServerFeatures.Get().Addresses.First().EndsWith(":0")) - { - break; - } - } - } - - Thread.Sleep(2000); - } - } - - [ClassCleanup] - public static async Task StopServer() - { - await _host.StopAsync(); - } - - [TestInitialize] - public void Reset() - { - MessageInspectorMock.Reset(); - } - - public ITestService CreateClient() - { - var addresses = _host.ServerFeatures.Get(); - var address = addresses.Addresses.Single(); - - var binding = new BasicHttpBinding(); - var endpoint = new EndpointAddress(new Uri(string.Format("{0}/Service.svc", address))); - var channelFactory = new ChannelFactory(binding, endpoint); - var serviceClient = channelFactory.CreateChannel(); - return serviceClient; - } - - [TestMethod] - [ExpectedException(typeof(FaultException))] - public void AfterReceivedRequestCalled() - { - Assert.IsFalse(MessageInspectorMock.AfterReceivedRequestCalled); - var client = CreateClient(); - var result = client.Ping("Hello World"); - Assert.IsTrue(MessageInspectorMock.AfterReceivedRequestCalled); - } - - [TestMethod] - [ExpectedException(typeof(FaultException))] - public void BeforeSendReplyShouldNotBeCalled() - { - Assert.IsFalse(MessageInspectorMock.BeforeSendReplyCalled); - var client = CreateClient(); - var result = client.Ping("Hello World"); - Assert.IsFalse(MessageInspectorMock.BeforeSendReplyCalled); - } - - [TestMethod] - public void AfterReceivedThrowsException() - { - var client = CreateClient(); - Assert.ThrowsException(() => client.Ping("Hello World")); - } - } -} diff --git a/src/SoapCore.Tests/MessageInspectors/MessageInspector2/MessageInspector2Tests.cs b/src/SoapCore.Tests/MessageInspectors/MessageInspector2/MessageInspector2Tests.cs index 7758aa92..b25fd14e 100644 --- a/src/SoapCore.Tests/MessageInspectors/MessageInspector2/MessageInspector2Tests.cs +++ b/src/SoapCore.Tests/MessageInspectors/MessageInspector2/MessageInspector2Tests.cs @@ -19,7 +19,6 @@ public static void StartServer(TestContext testContext) .UseKestrel() .UseUrls("http://localhost:7051") .UseStartup() - .UseSetting("InspectorStyle", InspectorStyle.MessageInspector2.ToString()) .Build(); host.Run(); diff --git a/src/SoapCore.Tests/MessageInspectors/Startup.cs b/src/SoapCore.Tests/MessageInspectors/Startup.cs index 9eaa1c77..95991e84 100644 --- a/src/SoapCore.Tests/MessageInspectors/Startup.cs +++ b/src/SoapCore.Tests/MessageInspectors/Startup.cs @@ -5,7 +5,6 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Logging; -using SoapCore.Tests.MessageInspectors.MessageInspector; using SoapCore.Tests.MessageInspectors.MessageInspector2; namespace SoapCore.Tests.MessageInspectors @@ -15,28 +14,16 @@ public class Startup public Startup(IConfiguration configuration) { Configuration = configuration; - InspectorStyle = configuration.GetValue("InspectorStyle"); } public IConfiguration Configuration { get; } - public InspectorStyle InspectorStyle { get; } public void ConfigureServices(IServiceCollection services) { services.AddSoapCore(); services.TryAddSingleton(); - switch (InspectorStyle) - { - case InspectorStyle.MessageInspector: -#pragma warning disable CS0612 // Type or member is obsolete - services.AddSoapMessageInspector(new MessageInspectorMock()); -#pragma warning restore CS0612 // Type or member is obsolete - break; - case InspectorStyle.MessageInspector2: - services.AddSoapMessageInspector(new MessageInspector2Mock()); - break; - } + services.AddSoapMessageInspector(new MessageInspector2Mock()); services.AddMvc(); } diff --git a/src/SoapCore.Tests/Serialization/DataContractSerializationTests.cs b/src/SoapCore.Tests/Serialization/DataContractSerializationTests.cs index 9de3a4b7..907c3207 100644 --- a/src/SoapCore.Tests/Serialization/DataContractSerializationTests.cs +++ b/src/SoapCore.Tests/Serialization/DataContractSerializationTests.cs @@ -199,67 +199,6 @@ public void TestPingComplexModelSerializationWithNoNameSpace(SoapSerializer soap pingComplexModelResult_client.ShouldDeepEqual(ComplexModel2.CreateSample2()); } - [Theory(Skip = "incompatible with all serializers")] - [MemberData(nameof(ServiceFixture.SoapSerializersList), MemberType = typeof(ServiceFixture))] - public void TestPingComplexModelOutAndRefSerialization(SoapSerializer soapSerializer) - { - var sampleServiceClient = _fixture.GetSampleServiceClient(soapSerializer); - - _fixture.ServiceMock - .Setup(x => x.PingComplexModelOutAndRef( - It.IsAny(), - ref It.Ref.IsAny, - It.IsAny(), - ref It.Ref.IsAny, - It.IsAny(), - out It.Ref.IsAny, - out It.Ref.IsAny)) - .Callback(new PingComplexModelOutAndRefCallback( - ( - ComplexModel1 inputModel_service, - ref ComplexModel2 responseModelRef1_service, - ComplexObject data1_service, - ref ComplexModel1 responseModelRef2_service, - ComplexObject data2_service, - out ComplexModel2 responseModelOut1_service, - out ComplexModel1 responseModelOut2_service) => - { - // check input paremeters serialization - inputModel_service.ShouldDeepEqual(ComplexModel1.CreateSample2()); - responseModelRef1_service.ShouldDeepEqual(ComplexModel2.CreateSample1()); - responseModelRef2_service.ShouldDeepEqual(ComplexModel1.CreateSample2()); - data1_service.ShouldDeepEqual(ComplexObject.CreateSample1()); - data2_service.ShouldDeepEqual(ComplexObject.CreateSample2()); - - //sample response - responseModelRef1_service = ComplexModel2.CreateSample2(); - responseModelRef2_service = ComplexModel1.CreateSample1(); - responseModelOut1_service = ComplexModel2.CreateSample3(); - responseModelOut2_service = ComplexModel1.CreateSample1(); - })) - .Returns(true); - - var responseModelRef1_client = ComplexModel2.CreateSample1(); - var responseModelRef2_client = ComplexModel1.CreateSample2(); - - var pingComplexModelOutAndRefResult_client = - sampleServiceClient.PingComplexModelOutAndRef( - ComplexModel1.CreateSample2(), - ref responseModelRef1_client, - ComplexObject.CreateSample1(), - ref responseModelRef2_client, - ComplexObject.CreateSample2(), - out var responseModelOut1_client, - out var responseModelOut2_client); - - // check output paremeters serialization - pingComplexModelOutAndRefResult_client.ShouldBeTrue(); - responseModelRef1_client.ShouldDeepEqual(ComplexModel2.CreateSample2()); - responseModelRef2_client.ShouldDeepEqual(ComplexModel1.CreateSample1()); - responseModelOut1_client.ShouldDeepEqual(ComplexModel2.CreateSample3()); - responseModelOut2_client.ShouldDeepEqual(ComplexModel1.CreateSample1()); - } - // not compatible with XmlSerializer [Theory] [InlineData(SoapSerializer.DataContractSerializer)] diff --git a/src/SoapCore.Tests/Serialization/XmlSerializationTests.cs b/src/SoapCore.Tests/Serialization/XmlSerializationTests.cs index d5dabecc..baa3c260 100644 --- a/src/SoapCore.Tests/Serialization/XmlSerializationTests.cs +++ b/src/SoapCore.Tests/Serialization/XmlSerializationTests.cs @@ -275,24 +275,6 @@ public void TestPingComplexArrayModel(SoapSerializer soapSerializer) result.ShouldDeepEqual(new[] { ComplexModel1.CreateSample1() }); } - [Theory(Skip = "test not correct")] - [InlineData(SoapSerializer.XmlSerializer)] - public void TestPingComplexArrayModelWithXmlArray(SoapSerializer soapSerializer) - { - var sampleServiceClient = _fixture.GetSampleServiceClient(soapSerializer); - - _fixture.ServiceMock - .Setup(x => x.PingComplexModelArray(It.IsAny(), It.IsAny())) - .Callback((ComplexModel1[] input, ComplexModel2[] input2) => - { - input.ShouldDeepEqual(new[] { ComplexModel1.CreateSample1() }); - input2.ShouldDeepEqual(new[] { ComplexModel2.CreateSample1() }); - }) - .Returns(new[] { ComplexModel1.CreateSample1() }); - var result = sampleServiceClient.PingComplexModelArrayWithXmlArray(new[] { ComplexModel1.CreateSample1() }, new[] { ComplexModel2.CreateSample1() }); - result.ShouldDeepEqual(new[] { ComplexModel1.CreateSample1() }); - } - [Theory] [InlineData(SoapSerializer.XmlSerializer)] public void TestPingStringArray(SoapSerializer soapSerializer) @@ -325,22 +307,6 @@ public void TestPingByteArray(SoapSerializer soapSerializer) result.ShouldDeepEqual(data); } - [Theory(Skip = "test not correct")] - [InlineData(SoapSerializer.XmlSerializer)] - public void TestPingStringArrayWithXmlArray(SoapSerializer soapSerializer) - { - var sampleServiceClient = _fixture.GetSampleServiceClient(soapSerializer); - - var data = new[] { "string", "string1" }; - - _fixture.ServiceMock - .Setup(x => x.PingStringArray(It.IsAny())) - .Callback((string[] input) => { input.ShouldDeepEqual(data); }) - .Returns(data); - var result = sampleServiceClient.PingStringArrayWithXmlArray(data); - result.ShouldDeepEqual(data); - } - [Theory] [InlineData(SoapSerializer.XmlSerializer)] public void TestResponseIntArray(SoapSerializer soapSerializer) @@ -818,29 +784,6 @@ public void TestPingComplexLegacyModelResponse(SoapSerializer soapSerializer) Assert.Equal(new[] { expected }, actual.UnqualifiedItems); } - //https://github.com/DigDes/SoapCore/issues/379 - [Theory(Skip = "not reproducible")] - [InlineData(SoapSerializer.XmlSerializer)] - public void TestParameterWithXmlElementNamespace(SoapSerializer soapSerializer) - { - var sampleServiceClient = _fixture.GetSampleServiceClient(soapSerializer); - var obj = new DataContractWithoutNamespace - { - IntProperty = 1234, - StringProperty = "2222" - }; - - _fixture.ServiceMock.Setup(x => x.GetComplexObjectWithXmlElement(obj)).Returns(obj); - _fixture.ServiceMock.Setup(x => x.GetComplexObjectWithXmlElement(It.IsAny())).Callback( - (DataContractWithoutNamespace o) => - { - Assert.Equal(obj.IntProperty, o.IntProperty); - Assert.Equal(obj.StringProperty, o.StringProperty); - }); - - sampleServiceClient.GetComplexObjectWithXmlElement(obj); - } - [Theory] [InlineData(SoapSerializer.XmlSerializer)] public void TestPingComplexMessageHeaderArraySerialization(SoapSerializer soapSerializer) diff --git a/src/SoapCore.Tests/SoapCore.Tests.csproj b/src/SoapCore.Tests/SoapCore.Tests.csproj index ebb13791..1749f046 100644 --- a/src/SoapCore.Tests/SoapCore.Tests.csproj +++ b/src/SoapCore.Tests/SoapCore.Tests.csproj @@ -1,7 +1,7 @@ - net7.0;net8.0 + net8.0 ..\SoapCore.ruleset false true @@ -16,11 +16,6 @@ - - - - - diff --git a/src/SoapCore.Tests/WsdlFromFile/Services/EchoIncludeSvc.cs b/src/SoapCore.Tests/WsdlFromFile/Services/EchoIncludeSvc.cs index 9e1ba2a5..0192736f 100644 --- a/src/SoapCore.Tests/WsdlFromFile/Services/EchoIncludeSvc.cs +++ b/src/SoapCore.Tests/WsdlFromFile/Services/EchoIncludeSvc.cs @@ -102,21 +102,6 @@ public IncludePortTypeClient() { } - public IncludePortTypeClient(string endpointConfigurationName) : - base(endpointConfigurationName) - { - } - - public IncludePortTypeClient(string endpointConfigurationName, string remoteAddress) : - base(endpointConfigurationName, remoteAddress) - { - } - - public IncludePortTypeClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) : - base(endpointConfigurationName, remoteAddress) - { - } - public IncludePortTypeClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) : base(binding, remoteAddress) { diff --git a/src/SoapCore.Tests/WsdlFromFile/Services/SnapshotPullSvc.cs b/src/SoapCore.Tests/WsdlFromFile/Services/SnapshotPullSvc.cs index 1f21ba05..396dad75 100644 --- a/src/SoapCore.Tests/WsdlFromFile/Services/SnapshotPullSvc.cs +++ b/src/SoapCore.Tests/WsdlFromFile/Services/SnapshotPullSvc.cs @@ -2118,11 +2118,6 @@ public virtual System.Threading.Tasks.Task OpenAsync() return System.Threading.Tasks.Task.Factory.FromAsync(((System.ServiceModel.ICommunicationObject)(this)).BeginOpen(null, null), new System.Action(((System.ServiceModel.ICommunicationObject)(this)).EndOpen)); } - public virtual System.Threading.Tasks.Task CloseAsync() - { - return System.Threading.Tasks.Task.Factory.FromAsync(((System.ServiceModel.ICommunicationObject)(this)).BeginClose(null, null), new System.Action(((System.ServiceModel.ICommunicationObject)(this)).EndClose)); - } - private static System.ServiceModel.Channels.Binding GetBindingForEndpoint(EndpointConfiguration endpointConfiguration) { if ((endpointConfiguration == EndpointConfiguration.snapshotPullSoapEndPoint)) diff --git a/src/SoapCore.Tests/XmlNodeInputOutput/Startup.cs b/src/SoapCore.Tests/XmlNodeInputOutput/Startup.cs index 674168b5..50cee563 100644 --- a/src/SoapCore.Tests/XmlNodeInputOutput/Startup.cs +++ b/src/SoapCore.Tests/XmlNodeInputOutput/Startup.cs @@ -1,34 +1,34 @@ -using System.IO; -using System.ServiceModel.Channels; -using System.Text; -using System.Threading.Tasks; -using System.Xml; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.DependencyInjection.Extensions; -using Microsoft.Extensions.Logging; - -namespace SoapCore.Tests.XmlNodeInputOutput -{ - public class Startup - { - public void ConfigureServices(IServiceCollection services) - { - services.AddSoapCore(); - services.TryAddSingleton(); - services.AddMvc(); - } - - public void Configure(IApplicationBuilder app) - { - app.UseRouting(); - - app.UseEndpoints(x => - { +using System.IO; +using System.ServiceModel.Channels; +using System.Text; +using System.Threading.Tasks; +using System.Xml; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection.Extensions; +using Microsoft.Extensions.Logging; + +namespace SoapCore.Tests.XmlNodeInputOutput +{ + public class Startup + { + public void ConfigureServices(IServiceCollection services) + { + services.AddSoapCore(); + services.TryAddSingleton(); + services.AddMvc(); + } + + public void Configure(IApplicationBuilder app) + { + app.UseRouting(); + + app.UseEndpoints(x => + { x.UseSoapEndpoint("/Service.svc", new SoapEncoderOptions(), SoapSerializer.DataContractSerializer); - x.UseSoapEndpoint("/Service.asmx", new SoapEncoderOptions(), SoapSerializer.XmlSerializer); - }); - } - } -} + x.UseSoapEndpoint("/Service.asmx", new SoapEncoderOptions(), SoapSerializer.XmlSerializer); + }); + } + } +} diff --git a/src/SoapCore/Extensibility/IMessageFilter.cs b/src/SoapCore/Extensibility/IMessageFilter.cs deleted file mode 100644 index c4e3647f..00000000 --- a/src/SoapCore/Extensibility/IMessageFilter.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.ServiceModel.Channels; - -namespace SoapCore.Extensibility -{ - [Obsolete] - public interface IMessageFilter - { - void OnRequestExecuting(Message message); - void OnResponseExecuting(Message message); - } -} diff --git a/src/SoapCore/Extensibility/IMessageInspector.cs b/src/SoapCore/Extensibility/IMessageInspector.cs deleted file mode 100644 index 2cf4418e..00000000 --- a/src/SoapCore/Extensibility/IMessageInspector.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.ServiceModel.Channels; - -namespace SoapCore.Extensibility -{ - [Obsolete] - public interface IMessageInspector - { - object AfterReceiveRequest(ref Message message); - void BeforeSendReply(ref Message reply, object correlationState); - } -} diff --git a/src/SoapCore/MessageEncoder/Requires.cs b/src/SoapCore/MessageEncoder/Requires.cs deleted file mode 100644 index 69b85482..00000000 --- a/src/SoapCore/MessageEncoder/Requires.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Diagnostics; - -namespace SoapCore.MessageEncoder -{ - [Obsolete] - internal static class Requires - { - [DebuggerStepThrough] - public static T NotNull(T value, string parameterName) - where T : class - { - if (value is null) - { - throw new ArgumentNullException(parameterName); - } - - return value; - } - } -} diff --git a/src/SoapCore/MessageEncoder/Verify.cs b/src/SoapCore/MessageEncoder/Verify.cs deleted file mode 100644 index 015d785e..00000000 --- a/src/SoapCore/MessageEncoder/Verify.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Diagnostics; - -namespace SoapCore.MessageEncoder -{ - [Obsolete] - internal static class Verify - { - [DebuggerStepThrough] - public static void Operation(bool condition, string message) - { - if (!condition) - { - throw new InvalidOperationException(message); - } - } - } -} diff --git a/src/SoapCore/Meta/BindingExtensions.cs b/src/SoapCore/Meta/BindingExtensions.cs deleted file mode 100644 index 0b382ea8..00000000 --- a/src/SoapCore/Meta/BindingExtensions.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using System.Net; -using System.ServiceModel.Channels; -using System.Text; -using System.Xml; - -namespace SoapCore.Meta -{ - [Obsolete] - internal static class BindingExtensions - { - public static bool HasBasicAuth(this Binding binding) - { - var transportBindingElement = binding?.CreateBindingElements().Find(); - - if (transportBindingElement != null) - { - return transportBindingElement.AuthenticationScheme == AuthenticationSchemes.Basic; - } - - return false; - } - - public static SoapEncoderOptions[] ToEncoderOptions(this Binding binding) - { - var elements = binding.CreateBindingElements().FindAll(); - var encoderOptions = new SoapEncoderOptions[elements.Count]; - - for (var i = 0; i < encoderOptions.Length; i++) - { - var encoderOption = new SoapEncoderOptions - { - MessageVersion = elements[i].MessageVersion, - WriteEncoding = DefaultEncodings.UTF8, - ReaderQuotas = XmlDictionaryReaderQuotas.Max - }; - - if (elements[i] is TextMessageEncodingBindingElement textMessageEncodingBindingElement) - { - encoderOption.WriteEncoding = textMessageEncodingBindingElement.WriteEncoding; - encoderOption.ReaderQuotas = textMessageEncodingBindingElement.ReaderQuotas; - } - - encoderOptions[i] = encoderOption; - } - - return encoderOptions; - } - } -} diff --git a/src/SoapCore/Meta/MetaBodyWriter.cs b/src/SoapCore/Meta/MetaBodyWriter.cs index 2d06ffe2..8861f7fa 100644 --- a/src/SoapCore/Meta/MetaBodyWriter.cs +++ b/src/SoapCore/Meta/MetaBodyWriter.cs @@ -36,21 +36,6 @@ public class MetaBodyWriter : BodyWriter private readonly bool _buildMicrosoftGuid = false; private IWsdlOperationNameGenerator _wsdlOperationNameGenerator; - - [Obsolete] - public MetaBodyWriter(ServiceDescription service, string baseUrl, Binding binding, XmlNamespaceManager xmlNamespaceManager = null) - : this( - service, - baseUrl, - xmlNamespaceManager ?? new XmlNamespaceManager(new NameTable()), - binding?.Name ?? "BasicHttpBinding_" + service.GeneralContract.Name, - new[] { new SoapBindingInfo(binding.MessageVersion ?? MessageVersion.None, null, null) }, - false, - new DefaultWsdlOperationNameGenerator()) - - { - } - public MetaBodyWriter(ServiceDescription service, string baseUrl, XmlNamespaceManager xmlNamespaceManager, string bindingName, SoapBindingInfo[] soapBindings, bool buildMicrosoftGuid, IWsdlOperationNameGenerator wsdlOperationNameGenerator) : base(isBuffered: true) { _service = service; diff --git a/src/SoapCore/Meta/MetaFromFile.cs b/src/SoapCore/Meta/MetaFromFile.cs index c379162c..556fab61 100644 --- a/src/SoapCore/Meta/MetaFromFile.cs +++ b/src/SoapCore/Meta/MetaFromFile.cs @@ -34,17 +34,6 @@ public class MetaFromFile /// public string ServerUrl { get; set; } - [Obsolete] - public string ReadLocalFile(string path) - { - if (!File.Exists(path)) - { - return string.Empty; - } - - return File.ReadAllText(path); - } - #if NETSTANDARD public async Task ReadLocalFileAsync(string path) { diff --git a/src/SoapCore/Meta/MetaMessage.cs b/src/SoapCore/Meta/MetaMessage.cs index 70f06bb5..534fd41c 100644 --- a/src/SoapCore/Meta/MetaMessage.cs +++ b/src/SoapCore/Meta/MetaMessage.cs @@ -15,14 +15,7 @@ public class MetaMessage : Message private readonly bool _hasBasicAuthentication; private readonly MessageVersion[] _soapVersions; - [Obsolete] - public MetaMessage(Message message, ServiceDescription service, Binding binding, XmlNamespaceManager xmlNamespaceManager) - : this(message, service, xmlNamespaceManager, binding?.Name, binding.HasBasicAuth(), [message.Version]) - { - } - - public MetaMessage(Message message, ServiceDescription service, XmlNamespaceManager xmlNamespaceManager, - string bindingName, bool hasBasicAuthentication, MessageVersion[] soapVersions) + public MetaMessage(Message message, ServiceDescription service, XmlNamespaceManager xmlNamespaceManager, string bindingName, bool hasBasicAuthentication, MessageVersion[] soapVersions) { _xmlNamespaceManager = xmlNamespaceManager; _message = message; diff --git a/src/SoapCore/Meta/MetaWCFBodyWriter.cs b/src/SoapCore/Meta/MetaWCFBodyWriter.cs index 2a0ed52f..5b379618 100644 --- a/src/SoapCore/Meta/MetaWCFBodyWriter.cs +++ b/src/SoapCore/Meta/MetaWCFBodyWriter.cs @@ -67,24 +67,7 @@ public class MetaWCFBodyWriter : BodyWriter private string _schemaNamespace; private IWsdlOperationNameGenerator _wsdlOperationNameGenerator; - [Obsolete] - public MetaWCFBodyWriter(ServiceDescription service, string baseUrl, Binding binding) - : this( - service, - baseUrl, - binding?.Name ?? "BasicHttpBinding_" + service.GeneralContract.Name, - binding.HasBasicAuth(), - new[] { new SoapBindingInfo(binding.MessageVersion ?? MessageVersion.None, null, null) }, - new DefaultWsdlOperationNameGenerator()) - { - } - - public MetaWCFBodyWriter(ServiceDescription service, - string baseUrl, - string bindingName, - bool hasBasicAuthentication, - SoapBindingInfo[] soapBindings, - IWsdlOperationNameGenerator wsdlOperationNameGenerator) : base(isBuffered: true) + public MetaWCFBodyWriter(ServiceDescription service, string baseUrl, string bindingName, bool hasBasicAuthentication, SoapBindingInfo[] soapBindings, IWsdlOperationNameGenerator wsdlOperationNameGenerator) : base(isBuffered: true) { _service = service; _baseUrl = baseUrl; diff --git a/src/SoapCore/ObsoleteMessageFilter.cs b/src/SoapCore/ObsoleteMessageFilter.cs deleted file mode 100644 index a9658f07..00000000 --- a/src/SoapCore/ObsoleteMessageFilter.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using System.ServiceModel.Channels; -using System.Threading.Tasks; -using SoapCore.Extensibility; - -namespace SoapCore -{ - [Obsolete] - internal sealed class ObsoleteMessageFilter : IAsyncMessageFilter - { - private readonly IMessageFilter _messageFilter; - - public ObsoleteMessageFilter(IMessageFilter messageFilter) - { - _messageFilter = messageFilter; - } - - public Task OnRequestExecuting(Message message) - { - _messageFilter.OnRequestExecuting(message); - return Task.CompletedTask; - } - - public Task OnResponseExecuting(Message message) - { - _messageFilter.OnResponseExecuting(message); - return Task.CompletedTask; - } - } -} diff --git a/src/SoapCore/ObsoleteMessageInspector.cs b/src/SoapCore/ObsoleteMessageInspector.cs deleted file mode 100644 index 9f14410e..00000000 --- a/src/SoapCore/ObsoleteMessageInspector.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.ServiceModel.Channels; -using SoapCore.Extensibility; -using SoapCore.ServiceModel; - -namespace SoapCore -{ - [Obsolete] - internal sealed class ObsoleteMessageInspector : IMessageInspector2 - { - private readonly IMessageInspector _inner; - - public ObsoleteMessageInspector(IMessageInspector inner) - { - _inner = inner; - } - - public object AfterReceiveRequest(ref Message message, ServiceDescription serviceDescription) - { - return _inner.AfterReceiveRequest(ref message); - } - - public void BeforeSendReply(ref Message reply, ServiceDescription serviceDescription, object correlationState) - { - _inner.BeforeSendReply(ref reply, correlationState); - } - } -} diff --git a/src/SoapCore/SoapCore.csproj b/src/SoapCore/SoapCore.csproj index cf02574b..c38c06ec 100644 --- a/src/SoapCore/SoapCore.csproj +++ b/src/SoapCore/SoapCore.csproj @@ -2,9 +2,9 @@ SOAP protocol middleware for ASP.NET Core - 1.1.0.51 + 1.2.0.0 Digital Design - netstandard2.0;netstandard2.1;netcoreapp3.1;net5.0;net6.0 + netstandard2.0;netstandard2.1;net8.0;netcoreapp3.1; SoapCore SOAP;ASP.NET Core https://github.com/DigDes/SoapCore @@ -36,24 +36,20 @@ - - + - + - - - - - - + - + + + @@ -64,11 +60,12 @@ - - + + all runtime; build; native; contentfiles; analyzers + diff --git a/src/SoapCore/SoapCoreOptions.cs b/src/SoapCore/SoapCoreOptions.cs index a2d141b5..01873047 100644 --- a/src/SoapCore/SoapCoreOptions.cs +++ b/src/SoapCore/SoapCoreOptions.cs @@ -11,11 +11,17 @@ public class SoapCoreOptions { private bool? _indentWsdl = null; +#if NET8_0_OR_GREATER + /// + /// Gets or sets the Path of the Service + /// + required public string Path { get; set; } +#else /// /// Gets or sets the Path of the Service /// public string Path { get; set; } - +#endif /// /// Gets or sets encoders /// @@ -39,13 +45,6 @@ public class SoapCoreOptions /// public ISoapModelBounder SoapModelBounder { get; set; } = null; - /// - /// Gets or sets a value indicating the binding to use - /// Defaults to null - /// - [Obsolete] - public Binding Binding { get; set; } - /// /// Gets or sets a value whether to use basic authentication /// Defaults to false @@ -76,20 +75,6 @@ public class SoapCoreOptions /// public bool HttpsPostEnabled { get; set; } = true; - /// - /// The maximum size in bytes of the in-memory used to buffer the - /// stream. Larger request bodies are written to disk. - /// - [Obsolete] - public int BufferThreshold { get; set; } = 1024 * 30; - - /// - /// The maximum size in bytes of the request body. An attempt to read beyond this limit will cause an - /// . - /// - [Obsolete] - public long BufferLimit { get; set; } - /// /// Gets or sets a value indicating whether to omit the Xml declaration (<?xml version="1.0" encoding="utf-8"?>) in responses /// Defaults to true diff --git a/src/SoapCore/SoapEndpointExtensions.cs b/src/SoapCore/SoapEndpointExtensions.cs index 86a78df6..f216da2b 100644 --- a/src/SoapCore/SoapEndpointExtensions.cs +++ b/src/SoapCore/SoapEndpointExtensions.cs @@ -50,32 +50,6 @@ public static IApplicationBuilder UseSoapEndpoint(this IApplicationBu }); } - [Obsolete] - public static IApplicationBuilder UseSoapEndpoint(this IApplicationBuilder builder, Type type, string path, SoapEncoderOptions encoder, SoapSerializer serializer, bool caseInsensitivePath, ISoapModelBounder soapModelBounder, Binding binding, bool indentXml, bool omitXmlDeclaration) - { - return builder.UseSoapEndpoint(type, path, new[] { encoder }, serializer, caseInsensitivePath, soapModelBounder, binding, null, indentXml, omitXmlDeclaration); - } - - [Obsolete] - public static IApplicationBuilder UseSoapEndpoint(this IApplicationBuilder builder, Type type, string path, SoapEncoderOptions encoder, SoapSerializer serializer, bool caseInsensitivePath, ISoapModelBounder soapModelBounder, Binding binding, bool indentXml, bool omitXmlDeclaration) - where T_MESSAGE : CustomMessage, new() - { - return builder.UseSoapEndpoint(type, path, new[] { encoder }, serializer, caseInsensitivePath, soapModelBounder, binding, null, indentXml, omitXmlDeclaration); - } - - [Obsolete] - public static IApplicationBuilder UseSoapEndpoint(this IApplicationBuilder builder, string path, Binding binding, SoapSerializer serializer, bool caseInsensitivePath, ISoapModelBounder soapModelBounder, WsdlFileOptions wsdlFileOptions, bool indentXml, bool omitXmlDeclaration) - { - return builder.UseSoapEndpoint(typeof(T), path, binding, serializer, caseInsensitivePath, soapModelBounder, wsdlFileOptions, indentXml, omitXmlDeclaration); - } - - [Obsolete] - public static IApplicationBuilder UseSoapEndpoint(this IApplicationBuilder builder, string path, Binding binding, SoapSerializer serializer, bool caseInsensitivePath, ISoapModelBounder soapModelBounder, bool indentXml, bool omitXmlDeclaration) - where T_MESSAGE : CustomMessage, new() - { - return builder.UseSoapEndpoint(typeof(T), path, binding, serializer, caseInsensitivePath, soapModelBounder, null, indentXml, omitXmlDeclaration); - } - public static IApplicationBuilder UseSoapEndpoint(this IApplicationBuilder builder, string path, SoapEncoderOptions[] encoders, SoapSerializer serializer = SoapSerializer.DataContractSerializer, bool caseInsensitivePath = false, ISoapModelBounder soapModelBounder = null, bool indentXml = true, bool omitXmlDeclaration = true) { return builder.UseSoapEndpoint(path, encoders, serializer, caseInsensitivePath, soapModelBounder, indentXml, omitXmlDeclaration); @@ -96,54 +70,6 @@ public static IApplicationBuilder UseSoapEndpoint(this IApplicatio }); } - [Obsolete] - public static IApplicationBuilder UseSoapEndpoint(this IApplicationBuilder builder, Type type, string path, SoapEncoderOptions[] encoderOptions, SoapSerializer serializer, bool caseInsensitivePath, ISoapModelBounder soapModelBounder, Binding binding, WsdlFileOptions wsdlFileOptions, bool indentXml, bool omitXmlDeclaration) - { - return builder.UseSoapEndpoint(type, path, encoderOptions, serializer, caseInsensitivePath, soapModelBounder, binding, wsdlFileOptions, indentXml, omitXmlDeclaration); - } - - [Obsolete] - public static IApplicationBuilder UseSoapEndpoint(this IApplicationBuilder builder, Type type, string path, SoapEncoderOptions[] encoderOptions, SoapSerializer serializer, bool caseInsensitivePath, ISoapModelBounder soapModelBounder, Binding binding, WsdlFileOptions wsdlFileOptions, bool indentXml, bool omitXmlDeclaration) - where T_MESSAGE : CustomMessage, new() - { - return UseSoapEndpoint(builder, type, options => - { - options.Path = path; - options.UseBasicAuthentication = binding.HasBasicAuth(); - options.EncoderOptions = encoderOptions ?? binding.ToEncoderOptions(); - options.CaseInsensitivePath = caseInsensitivePath; - options.SoapSerializer = serializer; - options.SoapModelBounder = soapModelBounder; - options.WsdlFileOptions = wsdlFileOptions; - options.IndentXml = indentXml; - options.OmitXmlDeclaration = omitXmlDeclaration; - }); - } - - [Obsolete] - public static IApplicationBuilder UseSoapEndpoint(this IApplicationBuilder builder, Type type, string path, Binding binding, SoapSerializer serializer, bool caseInsensitivePath, ISoapModelBounder soapModelBounder, WsdlFileOptions wsdlFileOptions, bool indentXml, bool omitXmlDeclaration) - { - return builder.UseSoapEndpoint(type, path, binding, serializer, caseInsensitivePath, soapModelBounder, wsdlFileOptions, indentXml, omitXmlDeclaration); - } - - [Obsolete] - public static IApplicationBuilder UseSoapEndpoint(this IApplicationBuilder builder, Type type, string path, Binding binding, SoapSerializer serializer, bool caseInsensitivePath, ISoapModelBounder soapModelBounder, WsdlFileOptions wsdlFileOptions, bool indentXml, bool omitXmlDeclaration) - where T_MESSAGE : CustomMessage, new() - { - return UseSoapEndpoint(builder, type, options => - { - options.Path = path; - options.UseBasicAuthentication = binding.HasBasicAuth(); - options.EncoderOptions = binding.ToEncoderOptions(); - options.SoapSerializer = serializer; - options.CaseInsensitivePath = caseInsensitivePath; - options.SoapModelBounder = soapModelBounder; - options.WsdlFileOptions = wsdlFileOptions; - options.IndentXml = indentXml; - options.OmitXmlDeclaration = omitXmlDeclaration; - }); - } - public static IApplicationBuilder UseSoapEndpoint(this IApplicationBuilder builder, Type serviceType, Action options) { return builder.UseSoapEndpoint(serviceType, options); @@ -163,7 +89,7 @@ public static IApplicationBuilder UseSoapEndpoint(this IApplicatio public static IApplicationBuilder UseSoapEndpoint(this IApplicationBuilder builder, Type serviceType, Action options) where T_MESSAGE : CustomMessage, new() { - var opt = new SoapCoreOptions(); + var opt = new SoapCoreOptions() { Path = string.Empty }; options(opt); var soapOptions = SoapOptions.FromSoapCoreOptions(opt, serviceType); @@ -204,43 +130,6 @@ public static IEndpointConventionBuilder UseSoapEndpoint(this IEndpoi }); } - [Obsolete] - public static IEndpointConventionBuilder UseSoapEndpoint(this IEndpointRouteBuilder routes, Type type, string path, SoapEncoderOptions encoder, SoapSerializer serializer, bool caseInsensitivePath, ISoapModelBounder soapModelBounder, Binding binding, bool indentXml, bool omitXmlDeclaration) - { - return routes.UseSoapEndpoint(type, path, encoder, serializer, caseInsensitivePath, soapModelBounder, binding, null, indentXml, omitXmlDeclaration); - } - - [Obsolete] - public static IEndpointConventionBuilder UseSoapEndpoint(this IEndpointRouteBuilder routes, Type type, string path, SoapEncoderOptions encoder, SoapSerializer serializer, bool caseInsensitivePath, ISoapModelBounder soapModelBounder, Binding binding, WsdlFileOptions wsdlFileOptions, bool indentXml, bool omitXmlDeclaration) - where T_MESSAGE : CustomMessage, new() - { - return routes.UseSoapEndpoint(type, options => - { - options.Path = path; - options.UseBasicAuthentication = binding.HasBasicAuth(); - options.EncoderOptions = SoapEncoderOptions.ToArray(encoder) ?? binding.ToEncoderOptions(); - options.SoapSerializer = serializer; - options.CaseInsensitivePath = caseInsensitivePath; - options.SoapModelBounder = soapModelBounder; - options.WsdlFileOptions = wsdlFileOptions; - options.IndentXml = indentXml; - options.OmitXmlDeclaration = omitXmlDeclaration; - }); - } - - [Obsolete] - public static IEndpointConventionBuilder UseSoapEndpoint(this IEndpointRouteBuilder routes, string path, Binding binding, SoapSerializer serializer, bool caseInsensitivePath, ISoapModelBounder soapModelBounder, WsdlFileOptions wsdlFileOptions, bool indentXml, bool omitXmlDeclaration) - { - return routes.UseSoapEndpoint(typeof(T), path, binding, serializer, caseInsensitivePath, soapModelBounder, wsdlFileOptions: wsdlFileOptions, indentXml: indentXml, omitXmlDeclaration: omitXmlDeclaration); - } - - [Obsolete] - public static IEndpointConventionBuilder UseSoapEndpoint(this IEndpointRouteBuilder routes, string path, Binding binding, SoapSerializer serializer, bool caseInsensitivePath, ISoapModelBounder soapModelBounder, bool indentXml, bool omitXmlDeclaration) - where T_MESSAGE : CustomMessage, new() - { - return routes.UseSoapEndpoint(typeof(T), path, binding, serializer, caseInsensitivePath, soapModelBounder, null, indentXml, omitXmlDeclaration); - } - public static IEndpointConventionBuilder UseSoapEndpoint(this IEndpointRouteBuilder routes, string path, SoapEncoderOptions[] encoders, SoapSerializer serializer = SoapSerializer.DataContractSerializer, bool caseInsensitivePath = false, ISoapModelBounder soapModelBounder = null, WsdlFileOptions wsdlFileOptions = null, bool indentXml = true, bool omitXmlDeclaration = true) { return routes.UseSoapEndpoint(path, encoders, serializer, caseInsensitivePath, soapModelBounder, wsdlFileOptions, indentXml, omitXmlDeclaration); @@ -268,54 +157,6 @@ public static IEndpointConventionBuilder UseSoapEndpoint(this IEnd }); } - [Obsolete] - public static IEndpointConventionBuilder UseSoapEndpoint(this IEndpointRouteBuilder routes, Type type, string path, SoapEncoderOptions[] encoders, SoapSerializer serializer, bool caseInsensitivePath, ISoapModelBounder soapModelBounder, Binding binding, WsdlFileOptions wsdlFileOptions, bool indentXml, bool omitXmlDeclaration) - where T_MESSAGE : CustomMessage, new() - { - return UseSoapEndpoint(routes, type, options => - { - options.Path = path; - options.UseBasicAuthentication = binding.HasBasicAuth(); - options.EncoderOptions = encoders ?? binding.ToEncoderOptions(); - options.CaseInsensitivePath = caseInsensitivePath; - options.SoapSerializer = serializer; - options.SoapModelBounder = soapModelBounder; - options.WsdlFileOptions = wsdlFileOptions; - options.IndentXml = indentXml; - options.OmitXmlDeclaration = omitXmlDeclaration; - }); - } - - [Obsolete] - public static IEndpointConventionBuilder UseSoapEndpoint(this IEndpointRouteBuilder routes, Type type, string path, SoapEncoderOptions[] encoders, SoapSerializer serializer, bool caseInsensitivePath, ISoapModelBounder soapModelBounder, Binding binding, WsdlFileOptions wsdlFileOptions, bool indentXml, bool omitXmlDeclaration) - { - return UseSoapEndpoint(routes, type, path, encoders, serializer, caseInsensitivePath, soapModelBounder, binding, wsdlFileOptions, indentXml, omitXmlDeclaration); - } - - [Obsolete] - public static IEndpointConventionBuilder UseSoapEndpoint(this IEndpointRouteBuilder routes, Type type, string path, Binding binding, SoapSerializer serializer, bool caseInsensitivePath, ISoapModelBounder soapModelBounder, WsdlFileOptions wsdlFileOptions, bool indentXml, bool omitXmlDeclaration) - where T_MESSAGE : CustomMessage, new() - { - return UseSoapEndpoint(routes, type, options => - { - options.Path = path; - options.UseBasicAuthentication = binding.HasBasicAuth(); - options.EncoderOptions = binding.ToEncoderOptions(); - options.SoapSerializer = serializer; - options.CaseInsensitivePath = caseInsensitivePath; - options.SoapModelBounder = soapModelBounder; - options.WsdlFileOptions = wsdlFileOptions; - options.IndentXml = indentXml; - options.OmitXmlDeclaration = omitXmlDeclaration; - }); - } - - [Obsolete] - public static IEndpointConventionBuilder UseSoapEndpoint(this IEndpointRouteBuilder routes, Type type, string path, Binding binding, SoapSerializer serializer, bool caseInsensitivePath, ISoapModelBounder soapModelBounder, WsdlFileOptions wsdlFileOptions, bool indentXml, bool omitXmlDeclaration) - { - return UseSoapEndpoint(routes, type, path, binding, serializer, caseInsensitivePath, soapModelBounder, wsdlFileOptions, indentXml, omitXmlDeclaration); - } - public static IEndpointConventionBuilder UseSoapEndpoint(this IEndpointRouteBuilder routes, Type serviceType, Action options) { return routes.UseSoapEndpoint(serviceType, options); @@ -330,7 +171,7 @@ public static IEndpointConventionBuilder UseSoapEndpoint(this IEnd public static IEndpointConventionBuilder UseSoapEndpoint(this IEndpointRouteBuilder routes, Type serviceType, Action options) where T_MESSAGE : CustomMessage, new() { - var opt = new SoapCoreOptions(); + var opt = new SoapCoreOptions() { Path = string.Empty }; options(opt); var soapOptions = SoapOptions.FromSoapCoreOptions(opt, serviceType); @@ -381,12 +222,6 @@ public static IServiceCollection AddSoapExceptionTransformer(this IServiceCollec return serviceCollection; } - [Obsolete] - public static IServiceCollection AddSoapMessageInspector(this IServiceCollection serviceCollection, IMessageInspector messageInspector) - { - return serviceCollection.AddSoapMessageInspector(new ObsoleteMessageInspector(messageInspector)); - } - public static IServiceCollection AddSoapMessageInspector(this IServiceCollection serviceCollection) where TService : class, IMessageInspector2 { @@ -400,12 +235,6 @@ public static IServiceCollection AddSoapMessageInspector(this IServiceCollection return serviceCollection; } - [Obsolete] - public static IServiceCollection AddSoapMessageFilter(this IServiceCollection serviceCollection, IMessageFilter messageFilter) - { - return serviceCollection.AddSoapMessageFilter(new ObsoleteMessageFilter(messageFilter)); - } - public static IServiceCollection AddSoapMessageFilter(this IServiceCollection serviceCollection, IAsyncMessageFilter messageFilter) { serviceCollection.AddSingleton(messageFilter); diff --git a/src/SoapCore/SoapEndpointMiddleware.cs b/src/SoapCore/SoapEndpointMiddleware.cs index 2b01160b..46093bbb 100644 --- a/src/SoapCore/SoapEndpointMiddleware.cs +++ b/src/SoapCore/SoapEndpointMiddleware.cs @@ -42,32 +42,7 @@ public class SoapEndpointMiddleware private readonly SoapMessageEncoder[] _messageEncoders; private readonly IXmlSerializationHandler _serializerHandler; - [Obsolete] - public SoapEndpointMiddleware(ILogger> logger, RequestDelegate next, IServiceProvider serviceProvider, Type serviceType, string path, SoapEncoderOptions[] encoderOptions, SoapSerializer serializer, bool caseInsensitivePath, ISoapModelBounder soapModelBounder, Binding binding, bool httpGetEnabled, bool httpsGetEnabled) - : this( - logger, - next, - new SoapOptions() - { - ServiceType = serviceType, - Path = path, - EncoderOptions = encoderOptions ?? binding?.ToEncoderOptions(), - SoapSerializer = serializer, - CaseInsensitivePath = caseInsensitivePath, - SoapModelBounder = soapModelBounder, - UseBasicAuthentication = binding.HasBasicAuth(), - HttpGetEnabled = httpGetEnabled, - HttpsGetEnabled = httpsGetEnabled - }, - serviceProvider) - { - } - - public SoapEndpointMiddleware( - ILogger> logger, - RequestDelegate next, - SoapOptions options, - IServiceProvider serviceProvider) + public SoapEndpointMiddleware(ILogger> logger, RequestDelegate next, SoapOptions options, IServiceProvider serviceProvider) { _logger = logger; _next = next; diff --git a/src/SoapCore/SoapOptions.cs b/src/SoapCore/SoapOptions.cs index 5dc80d2b..8a71fd88 100644 --- a/src/SoapCore/SoapOptions.cs +++ b/src/SoapCore/SoapOptions.cs @@ -16,17 +16,8 @@ public class SoapOptions public SoapSerializer SoapSerializer { get; set; } public bool CaseInsensitivePath { get; set; } public ISoapModelBounder SoapModelBounder { get; set; } - - [Obsolete] - public Binding Binding { get; set; } - public bool UseBasicAuthentication { get; set; } - [Obsolete] - public int BufferThreshold { get; set; } - [Obsolete] - public long BufferLimit { get; set; } - /// /// Gets or sets a value indicating whether publication of service metadata on HTTP GET request, and invocation of service operation by GET, is activated /// Defaults to true @@ -113,21 +104,6 @@ public static SoapOptions FromSoapCoreOptions(SoapCoreOptions opt, Type serviceT NormalizeNewLines = opt.NormalizeNewLines, }; -#pragma warning disable CS0612 // Type or member is obsolete - if (opt.Binding is object) - { - if (opt.Binding.HasBasicAuth()) - { - options.UseBasicAuthentication = true; - } - - if (options.EncoderOptions is null) - { - opt.EncoderOptions = opt.Binding.ToEncoderOptions(); - } - } -#pragma warning restore CS0612 // Type or member is obsolete - return options; } }