diff --git a/Extensibility/MessageEncoder/Text/Client/Client.csproj b/Extensibility/MessageEncoder/Text/Client/Client.csproj
new file mode 100644
index 0000000..d400073
--- /dev/null
+++ b/Extensibility/MessageEncoder/Text/Client/Client.csproj
@@ -0,0 +1,25 @@
+
+
+
+ Exe
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Extensibility/MessageEncoder/Text/Client/Connected Services/CoreWcf.Samples.TextMessageEncoder/ConnectedService.json b/Extensibility/MessageEncoder/Text/Client/Connected Services/CoreWcf.Samples.TextMessageEncoder/ConnectedService.json
new file mode 100644
index 0000000..eeeb1ae
--- /dev/null
+++ b/Extensibility/MessageEncoder/Text/Client/Connected Services/CoreWcf.Samples.TextMessageEncoder/ConnectedService.json
@@ -0,0 +1,17 @@
+{
+ "ExtendedData": {
+ "inputs": [
+ "https://localhost:5001/CalculatorService?wsdl"
+ ],
+ "collectionTypes": [
+ "System.Array",
+ "System.Collections.Generic.Dictionary`2"
+ ],
+ "namespaceMappings": [
+ "*, CoreWcf.Samples.TextMessageEncoder"
+ ],
+ "sync": true,
+ "targetFramework": "net6.0",
+ "typeReuseMode": "All"
+ }
+}
\ No newline at end of file
diff --git a/Extensibility/MessageEncoder/Text/Client/Connected Services/CoreWcf.Samples.TextMessageEncoder/Reference.cs b/Extensibility/MessageEncoder/Text/Client/Connected Services/CoreWcf.Samples.TextMessageEncoder/Reference.cs
new file mode 100644
index 0000000..38428e9
--- /dev/null
+++ b/Extensibility/MessageEncoder/Text/Client/Connected Services/CoreWcf.Samples.TextMessageEncoder/Reference.cs
@@ -0,0 +1,182 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace CoreWcf.Samples.TextMessageEncoder
+{
+
+
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.1.0")]
+ [System.ServiceModel.ServiceContractAttribute(ConfigurationName="CoreWcf.Samples.TextMessageEncoder.ICalculatorService")]
+ public interface ICalculatorService
+ {
+
+ [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ICalculatorService/Add", ReplyAction="http://tempuri.org/ICalculatorService/AddResponse")]
+ double Add(double n1, double n2);
+
+ [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ICalculatorService/Add", ReplyAction="http://tempuri.org/ICalculatorService/AddResponse")]
+ System.Threading.Tasks.Task AddAsync(double n1, double n2);
+
+ [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ICalculatorService/Subtract", ReplyAction="http://tempuri.org/ICalculatorService/SubtractResponse")]
+ double Subtract(double n1, double n2);
+
+ [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ICalculatorService/Subtract", ReplyAction="http://tempuri.org/ICalculatorService/SubtractResponse")]
+ System.Threading.Tasks.Task SubtractAsync(double n1, double n2);
+
+ [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ICalculatorService/Multiply", ReplyAction="http://tempuri.org/ICalculatorService/MultiplyResponse")]
+ double Multiply(double n1, double n2);
+
+ [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ICalculatorService/Multiply", ReplyAction="http://tempuri.org/ICalculatorService/MultiplyResponse")]
+ System.Threading.Tasks.Task MultiplyAsync(double n1, double n2);
+
+ [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ICalculatorService/Divide", ReplyAction="http://tempuri.org/ICalculatorService/DivideResponse")]
+ double Divide(double n1, double n2);
+
+ [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ICalculatorService/Divide", ReplyAction="http://tempuri.org/ICalculatorService/DivideResponse")]
+ System.Threading.Tasks.Task DivideAsync(double n1, double n2);
+ }
+
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.1.0")]
+ public interface ICalculatorServiceChannel : CoreWcf.Samples.TextMessageEncoder.ICalculatorService, System.ServiceModel.IClientChannel
+ {
+ }
+
+ [System.Diagnostics.DebuggerStepThroughAttribute()]
+ [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.Tools.ServiceModel.Svcutil", "2.1.0")]
+ public partial class CalculatorServiceClient : System.ServiceModel.ClientBase, CoreWcf.Samples.TextMessageEncoder.ICalculatorService
+ {
+
+ ///
+ /// Implement this partial method to configure the service endpoint.
+ ///
+ /// The endpoint to configure
+ /// The client credentials
+ static partial void ConfigureEndpoint(System.ServiceModel.Description.ServiceEndpoint serviceEndpoint, System.ServiceModel.Description.ClientCredentials clientCredentials);
+
+ public CalculatorServiceClient() :
+ base(CalculatorServiceClient.GetDefaultBinding(), CalculatorServiceClient.GetDefaultEndpointAddress())
+ {
+ this.Endpoint.Name = EndpointConfiguration.CustomBinding_ICalculatorService.ToString();
+ ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
+ }
+
+ public CalculatorServiceClient(EndpointConfiguration endpointConfiguration) :
+ base(CalculatorServiceClient.GetBindingForEndpoint(endpointConfiguration), CalculatorServiceClient.GetEndpointAddress(endpointConfiguration))
+ {
+ this.Endpoint.Name = endpointConfiguration.ToString();
+ ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
+ }
+
+ public CalculatorServiceClient(EndpointConfiguration endpointConfiguration, string remoteAddress) :
+ base(CalculatorServiceClient.GetBindingForEndpoint(endpointConfiguration), new System.ServiceModel.EndpointAddress(remoteAddress))
+ {
+ this.Endpoint.Name = endpointConfiguration.ToString();
+ ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
+ }
+
+ public CalculatorServiceClient(EndpointConfiguration endpointConfiguration, System.ServiceModel.EndpointAddress remoteAddress) :
+ base(CalculatorServiceClient.GetBindingForEndpoint(endpointConfiguration), remoteAddress)
+ {
+ this.Endpoint.Name = endpointConfiguration.ToString();
+ ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
+ }
+
+ public CalculatorServiceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
+ base(binding, remoteAddress)
+ {
+ }
+
+ public double Add(double n1, double n2)
+ {
+ return base.Channel.Add(n1, n2);
+ }
+
+ public System.Threading.Tasks.Task AddAsync(double n1, double n2)
+ {
+ return base.Channel.AddAsync(n1, n2);
+ }
+
+ public double Subtract(double n1, double n2)
+ {
+ return base.Channel.Subtract(n1, n2);
+ }
+
+ public System.Threading.Tasks.Task SubtractAsync(double n1, double n2)
+ {
+ return base.Channel.SubtractAsync(n1, n2);
+ }
+
+ public double Multiply(double n1, double n2)
+ {
+ return base.Channel.Multiply(n1, n2);
+ }
+
+ public System.Threading.Tasks.Task MultiplyAsync(double n1, double n2)
+ {
+ return base.Channel.MultiplyAsync(n1, n2);
+ }
+
+ public double Divide(double n1, double n2)
+ {
+ return base.Channel.Divide(n1, n2);
+ }
+
+ public System.Threading.Tasks.Task DivideAsync(double n1, double n2)
+ {
+ return base.Channel.DivideAsync(n1, n2);
+ }
+
+ 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));
+ }
+
+ private static System.ServiceModel.Channels.Binding GetBindingForEndpoint(EndpointConfiguration endpointConfiguration)
+ {
+ if ((endpointConfiguration == EndpointConfiguration.CustomBinding_ICalculatorService))
+ {
+ System.ServiceModel.Channels.CustomBinding result = new System.ServiceModel.Channels.CustomBinding();
+ System.ServiceModel.Channels.TextMessageEncodingBindingElement textBindingElement = new System.ServiceModel.Channels.TextMessageEncodingBindingElement();
+ textBindingElement.MessageVersion = System.ServiceModel.Channels.MessageVersion.CreateVersion(System.ServiceModel.EnvelopeVersion.Soap11, System.ServiceModel.Channels.AddressingVersion.WSAddressing10);
+ result.Elements.Add(textBindingElement);
+ System.ServiceModel.Channels.HttpsTransportBindingElement httpsBindingElement = new System.ServiceModel.Channels.HttpsTransportBindingElement();
+ httpsBindingElement.AllowCookies = true;
+ httpsBindingElement.MaxBufferSize = int.MaxValue;
+ httpsBindingElement.MaxReceivedMessageSize = int.MaxValue;
+ result.Elements.Add(httpsBindingElement);
+ return result;
+ }
+ throw new System.InvalidOperationException(string.Format("Could not find endpoint with name \'{0}\'.", endpointConfiguration));
+ }
+
+ private static System.ServiceModel.EndpointAddress GetEndpointAddress(EndpointConfiguration endpointConfiguration)
+ {
+ if ((endpointConfiguration == EndpointConfiguration.CustomBinding_ICalculatorService))
+ {
+ return new System.ServiceModel.EndpointAddress("https://localhost:5001/CalculatorService");
+ }
+ throw new System.InvalidOperationException(string.Format("Could not find endpoint with name \'{0}\'.", endpointConfiguration));
+ }
+
+ private static System.ServiceModel.Channels.Binding GetDefaultBinding()
+ {
+ return CalculatorServiceClient.GetBindingForEndpoint(EndpointConfiguration.CustomBinding_ICalculatorService);
+ }
+
+ private static System.ServiceModel.EndpointAddress GetDefaultEndpointAddress()
+ {
+ return CalculatorServiceClient.GetEndpointAddress(EndpointConfiguration.CustomBinding_ICalculatorService);
+ }
+
+ public enum EndpointConfiguration
+ {
+
+ CustomBinding_ICalculatorService,
+ }
+ }
+}
diff --git a/Extensibility/MessageEncoder/Text/Client/Program.cs b/Extensibility/MessageEncoder/Text/Client/Program.cs
new file mode 100644
index 0000000..0864ffe
--- /dev/null
+++ b/Extensibility/MessageEncoder/Text/Client/Program.cs
@@ -0,0 +1,50 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+//The service contract is defined using Connected Service "WCF Web Service", generated from the service by the dotnet svcutil tool.
+
+BasicHttpBinding basicHttpBinding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
+HttpTransportBindingElement httpTransportBindingElement = basicHttpBinding.CreateBindingElements().Find();
+MessageEncodingBindingElement encodingBindingElement = new CustomTextMessageBindingElement("UTF-8", "application/soap+xml", MessageVersion.Soap12WSAddressing10);
+httpTransportBindingElement.TransferMode = TransferMode.Streamed;
+CustomBinding binding = new CustomBinding(new BindingElement[]
+{
+ encodingBindingElement,
+ httpTransportBindingElement
+});
+
+var endpointAddress = new EndpointAddress("https://localhost:5001/CalculatorService");
+
+// Create a client with given client endpoint configuration
+CalculatorServiceClient client = new CalculatorServiceClient(binding, endpointAddress);
+
+// Call the Add service operation.
+double value1 = 100.00D;
+double value2 = 15.99D;
+double result = client.Add(value1, value2);
+Console.WriteLine("Add({0},{1}) = {2}", value1, value2, result);
+
+// Call the Subtract service operation.
+value1 = 145.00D;
+value2 = 76.54D;
+result = client.Subtract(value1, value2);
+Console.WriteLine("Subtract({0},{1}) = {2}", value1, value2, result);
+
+// Call the Multiply service operation.
+value1 = 9.00D;
+value2 = 81.25D;
+result = client.Multiply(value1, value2);
+Console.WriteLine("Multiply({0},{1}) = {2}", value1, value2, result);
+
+// Call the Divide service operation.
+value1 = 22.00D;
+value2 = 7.00D;
+result = client.Divide(value1, value2);
+Console.WriteLine("Divide({0},{1}) = {2}", value1, value2, result);
+
+//Closing the client gracefully closes the connection and cleans up resources
+client.CloseAsync();
+
+Console.WriteLine();
+Console.WriteLine("Press to terminate client.");
+Console.ReadLine();
diff --git a/Extensibility/MessageEncoder/Text/Extensibility.MessageEncoder.Text.sln b/Extensibility/MessageEncoder/Text/Extensibility.MessageEncoder.Text.sln
new file mode 100644
index 0000000..bb57b5a
--- /dev/null
+++ b/Extensibility/MessageEncoder/Text/Extensibility.MessageEncoder.Text.sln
@@ -0,0 +1,43 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.2.32422.2
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Service", "Service\Service.csproj", "{BF126326-3393-407C-B24A-8FCCC388BE27}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Client", "Client\Client.csproj", "{B533CADA-93BB-40E1-8FBA-FE37100062C3}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CustomTextMessageEncoder_CoreWCF", "LibraryCoreWCF\CustomTextMessageEncoder_CoreWCF.csproj", "{D1EAF072-0F66-4BD0-BC53-D4ABC45163C5}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CustomTextMessageEncoder", "Library\CustomTextMessageEncoder.csproj", "{B1EAF072-4F66-FBD0-BC53-D4ABC45963C5}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {BF126326-3393-407C-B24A-8FCCC388BE27}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {BF126326-3393-407C-B24A-8FCCC388BE27}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {BF126326-3393-407C-B24A-8FCCC388BE27}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {BF126326-3393-407C-B24A-8FCCC388BE27}.Release|Any CPU.Build.0 = Release|Any CPU
+ {B533CADA-93BB-40E1-8FBA-FE37100062C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B533CADA-93BB-40E1-8FBA-FE37100062C3}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B533CADA-93BB-40E1-8FBA-FE37100062C3}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B533CADA-93BB-40E1-8FBA-FE37100062C3}.Release|Any CPU.Build.0 = Release|Any CPU
+ {D1EAF072-0F66-4BD0-BC53-D4ABC45163C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {D1EAF072-0F66-4BD0-BC53-D4ABC45163C5}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {D1EAF072-0F66-4BD0-BC53-D4ABC45163C5}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {D1EAF072-0F66-4BD0-BC53-D4ABC45163C5}.Release|Any CPU.Build.0 = Release|Any CPU
+ {B1EAF072-4F66-FBD0-BC53-D4ABC45963C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B1EAF072-4F66-FBD0-BC53-D4ABC45963C5}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B1EAF072-4F66-FBD0-BC53-D4ABC45963C5}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B1EAF072-4F66-FBD0-BC53-D4ABC45963C5}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {AD996EFD-70DC-4431-B411-5A2771DD02D3}
+ EndGlobalSection
+EndGlobal
diff --git a/Extensibility/MessageEncoder/Text/Library/CustomTextMessageEncoder.cs b/Extensibility/MessageEncoder/Text/Library/CustomTextMessageEncoder.cs
new file mode 100644
index 0000000..850f0d4
--- /dev/null
+++ b/Extensibility/MessageEncoder/Text/Library/CustomTextMessageEncoder.cs
@@ -0,0 +1,71 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System.Text;
+using System.Xml;
+
+namespace CoreWcf.Samples.CustomTextMessageEncoder
+{
+ public class CustomTextMessageEncoder : MessageEncoder
+ {
+ private readonly CustomTextMessageEncoderFactory _factory;
+ private readonly XmlWriterSettings _writerSettings;
+ private readonly string _contentType;
+
+ public CustomTextMessageEncoder(CustomTextMessageEncoderFactory factory)
+ {
+ _factory = factory;
+ _writerSettings = new XmlWriterSettings();
+ _writerSettings.Encoding = Encoding.GetEncoding(factory.CharSet);
+ _contentType = string.Format("{0}; charset={1}", _factory.MediaType, _writerSettings.Encoding.HeaderName);
+ }
+
+ public override string ContentType => _contentType;
+
+ public override string MediaType => _factory.MediaType;
+
+ public override MessageVersion MessageVersion => _factory.MessageVersion;
+
+ public override Message ReadMessage(ArraySegment buffer, BufferManager bufferManager, string contentType)
+ {
+ byte[] msgContents = new byte[buffer.Count];
+ Array.Copy(buffer.Array, buffer.Offset, msgContents, 0, msgContents.Length);
+ bufferManager.ReturnBuffer(buffer.Array);
+
+ return ReadMessage(msgContents, bufferManager);
+ }
+
+ public override Message ReadMessage(Stream stream, int maxSizeOfHeaders, string contentType)
+ {
+ XmlReader reader = XmlReader.Create(stream);
+ Message message = Message.CreateMessage(reader, maxSizeOfHeaders, MessageVersion);
+ return message;
+ }
+
+ public override ArraySegment WriteMessage(Message message, int maxMessageSize, BufferManager bufferManager, int messageOffset)
+ {
+ MemoryStream stream = new MemoryStream();
+ XmlWriter writer = XmlWriter.Create(stream, _writerSettings);
+ message.WriteMessage(writer);
+ writer.Close();
+
+ byte[] messageBytes = stream.GetBuffer();
+ int messageLength = (int)stream.Position;
+ stream.Close();
+
+ int totalLength = messageLength + messageOffset;
+ byte[] totalBytes = bufferManager.TakeBuffer(totalLength);
+ Array.Copy(messageBytes, 0, totalBytes, messageOffset, messageLength);
+
+ ArraySegment byteArray = new ArraySegment(totalBytes, messageOffset, messageLength);
+ return byteArray;
+ }
+
+ public override void WriteMessage(Message message, Stream stream)
+ {
+ XmlWriter writer = XmlWriter.Create(stream, _writerSettings);
+ message.WriteMessage(writer);
+ writer.Close();
+ }
+ }
+}
diff --git a/Extensibility/MessageEncoder/Text/Library/CustomTextMessageEncoder.csproj b/Extensibility/MessageEncoder/Text/Library/CustomTextMessageEncoder.csproj
new file mode 100644
index 0000000..fe91ceb
--- /dev/null
+++ b/Extensibility/MessageEncoder/Text/Library/CustomTextMessageEncoder.csproj
@@ -0,0 +1,18 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Extensibility/MessageEncoder/Text/Library/CustomTextMessageEncoderFactory.cs b/Extensibility/MessageEncoder/Text/Library/CustomTextMessageEncoderFactory.cs
new file mode 100644
index 0000000..ec9833d
--- /dev/null
+++ b/Extensibility/MessageEncoder/Text/Library/CustomTextMessageEncoderFactory.cs
@@ -0,0 +1,24 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+namespace CoreWcf.Samples.CustomTextMessageEncoder
+{
+ public class CustomTextMessageEncoderFactory : MessageEncoderFactory
+ {
+ internal CustomTextMessageEncoderFactory(string mediaType, string charSet, MessageVersion version)
+ {
+ MessageVersion = version;
+ MediaType = mediaType;
+ CharSet = charSet;
+ Encoder = new CustomTextMessageEncoder(this);
+ }
+
+ public override MessageEncoder Encoder { get; }
+
+ public override MessageVersion MessageVersion { get; }
+
+ internal string MediaType { get; }
+
+ internal string CharSet { get; }
+ }
+}
diff --git a/Extensibility/MessageEncoder/Text/Library/CustomTextMessageEncodingBindingElement.cs b/Extensibility/MessageEncoder/Text/Library/CustomTextMessageEncodingBindingElement.cs
new file mode 100644
index 0000000..76fc909
--- /dev/null
+++ b/Extensibility/MessageEncoder/Text/Library/CustomTextMessageEncodingBindingElement.cs
@@ -0,0 +1,110 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System.Xml;
+
+namespace CoreWcf.Samples.CustomTextMessageEncoder
+{
+ public class CustomTextMessageBindingElement : MessageEncodingBindingElement
+ {
+ private MessageVersion _msgVersion;
+ private string _mediaType;
+ private string _encoding;
+ private readonly XmlDictionaryReaderQuotas _readerQuotas;
+
+ public CustomTextMessageBindingElement(CustomTextMessageBindingElement binding)
+ : this(binding.Encoding, binding.MediaType, binding.MessageVersion)
+ {
+ _readerQuotas = new XmlDictionaryReaderQuotas();
+ binding.ReaderQuotas.CopyTo(_readerQuotas);
+ }
+
+ public CustomTextMessageBindingElement(string encoding, string mediaType, MessageVersion msgVersion)
+ {
+ _msgVersion = msgVersion ?? throw new ArgumentNullException(nameof(msgVersion));
+ _mediaType = mediaType ?? throw new ArgumentNullException(nameof(mediaType));
+ _encoding = encoding ?? throw new ArgumentNullException(nameof(encoding));
+ _readerQuotas = new XmlDictionaryReaderQuotas();
+ }
+
+ public CustomTextMessageBindingElement(string encoding, string mediaType)
+ : this(encoding, mediaType, MessageVersion.CreateVersion(EnvelopeVersion.Soap11, AddressingVersion.WSAddressing10))
+ {
+ }
+
+ public CustomTextMessageBindingElement(string encoding)
+ : this(encoding, "text/xml")
+ {
+ }
+
+ public CustomTextMessageBindingElement()
+ : this("UTF-8")
+ {
+ }
+
+ public override MessageVersion MessageVersion
+ {
+ get
+ {
+ return _msgVersion;
+ }
+
+ set
+ {
+ _msgVersion = value ?? throw new ArgumentNullException(nameof(value));
+ }
+ }
+
+ public string MediaType
+ {
+ get
+ {
+ return _mediaType;
+ }
+
+ set
+ {
+ _mediaType = value ?? throw new ArgumentNullException(nameof(value));
+ }
+ }
+
+ public string Encoding
+ {
+ get
+ {
+ return _encoding;
+ }
+
+ set
+ {
+ _encoding = value ?? throw new ArgumentNullException(nameof(value));
+ }
+ }
+
+ // This encoder does not enforces any quotas for the unsecure messages. The
+ // quotas are enforced for the secure portions of messages when this encoder
+ // is used in a binding that is configured with security.
+ public XmlDictionaryReaderQuotas ReaderQuotas => _readerQuotas;
+
+ #region IMessageEncodingBindingElement Members
+
+ public override MessageEncoderFactory CreateMessageEncoderFactory() => new CustomTextMessageEncoderFactory(MediaType, Encoding, MessageVersion);
+
+ #endregion
+
+ public override BindingElement Clone() => new CustomTextMessageBindingElement(this);
+
+ public override T GetProperty(BindingContext context)
+ {
+ if (typeof(T) == typeof(XmlDictionaryReaderQuotas))
+ {
+ return (T)(object)_readerQuotas;
+ }
+ else
+ {
+ return base.GetProperty(context);
+ }
+ }
+
+ }
+}
diff --git a/Extensibility/MessageEncoder/Text/LibraryCoreWCF/ConfigurationStrings.cs b/Extensibility/MessageEncoder/Text/LibraryCoreWCF/ConfigurationStrings.cs
new file mode 100644
index 0000000..4fb3503
--- /dev/null
+++ b/Extensibility/MessageEncoder/Text/LibraryCoreWCF/ConfigurationStrings.cs
@@ -0,0 +1,24 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+namespace CoreWcf.Samples.CustomTextMessageEncoder
+{
+ internal class ConfigurationStrings
+ {
+ internal const string MessageVersion = "messageVersion";
+ internal const string MediaType = "mediaType";
+ internal const string Encoding = "encoding";
+ internal const string ReaderQuotas = "readerQuotas";
+ internal const string None = "None";
+ internal const string Default = "Default";
+ internal const string Soap11 = "Soap11";
+ internal const string Soap11WSAddressing10 = "Soap11WSAddressing10";
+ internal const string Soap11WSAddressingAugust2004 = "Soap11WSAddressingAugust2004";
+ internal const string Soap12 = "Soap12";
+ internal const string Soap12WSAddressing10 = "Soap12WSAddressing10";
+ internal const string Soap12WSAddressingAugust2004 = "Soap12WSAddressingAugust2004";
+ internal const string DefaultMessageVersion = Soap12WSAddressing10;
+ internal const string DefaultMediaType = "text/xml";
+ internal const string DefaultEncoding = "utf-8";
+ }
+}
diff --git a/Extensibility/MessageEncoder/Text/LibraryCoreWCF/CustomTextMessageEncoder.cs b/Extensibility/MessageEncoder/Text/LibraryCoreWCF/CustomTextMessageEncoder.cs
new file mode 100644
index 0000000..88899a7
--- /dev/null
+++ b/Extensibility/MessageEncoder/Text/LibraryCoreWCF/CustomTextMessageEncoder.cs
@@ -0,0 +1,71 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System.Text;
+using System.Xml;
+
+namespace CoreWcf.Samples.CustomTextMessageEncoder
+{
+ public class CustomTextMessageEncoder : MessageEncoder
+ {
+ private readonly CustomTextMessageEncoderFactory _factory;
+ private readonly XmlWriterSettings _writerSettings;
+ private readonly string _contentType;
+
+ public CustomTextMessageEncoder(CustomTextMessageEncoderFactory factory)
+ {
+ _factory = factory;
+ _writerSettings = new XmlWriterSettings();
+ _writerSettings.Encoding = Encoding.GetEncoding(factory.CharSet);
+ _contentType = string.Format("{0}; charset={1}", _factory.MediaType, _writerSettings.Encoding.HeaderName);
+ }
+
+ public override string ContentType => _contentType;
+
+ public override string MediaType => _factory.MediaType;
+
+ public override MessageVersion MessageVersion => _factory.MessageVersion;
+
+ public override Message ReadMessage(ArraySegment buffer, BufferManager bufferManager, string contentType)
+ {
+ byte[] msgContents = new byte[buffer.Count];
+ Array.Copy(buffer.Array, buffer.Offset, msgContents, 0, msgContents.Length);
+ bufferManager.ReturnBuffer(buffer.Array);
+
+ return ReadMessage(msgContents, bufferManager);
+ }
+
+ public override Task ReadMessageAsync(Stream stream, int maxSizeOfHeaders, string contentType)
+ {
+ XmlReader reader = XmlReader.Create(stream);
+ Message message = Message.CreateMessage(reader, maxSizeOfHeaders, MessageVersion);
+ return Task.FromResult(message);
+ }
+
+ public override ArraySegment WriteMessage(Message message, int maxMessageSize, BufferManager bufferManager, int messageOffset)
+ {
+ MemoryStream stream = new MemoryStream();
+ XmlWriter writer = XmlWriter.Create(stream, _writerSettings);
+ message.WriteMessage(writer);
+ writer.Close();
+
+ byte[] messageBytes = stream.GetBuffer();
+ int messageLength = (int)stream.Position;
+ stream.Close();
+
+ int totalLength = messageLength + messageOffset;
+ byte[] totalBytes = bufferManager.TakeBuffer(totalLength);
+ Array.Copy(messageBytes, 0, totalBytes, messageOffset, messageLength);
+
+ ArraySegment byteArray = new ArraySegment(totalBytes, messageOffset, messageLength);
+ return byteArray;
+ }
+
+ public override async Task WriteMessageAsync(Message message, Stream stream)
+ {
+ XmlWriter writer = XmlWriter.Create(stream, _writerSettings);
+ await message.WriteMessageAsync(writer);
+ writer.Close();
+ }
+ }
+}
diff --git a/Extensibility/MessageEncoder/Text/LibraryCoreWCF/CustomTextMessageEncoderFactory.cs b/Extensibility/MessageEncoder/Text/LibraryCoreWCF/CustomTextMessageEncoderFactory.cs
new file mode 100644
index 0000000..ec9833d
--- /dev/null
+++ b/Extensibility/MessageEncoder/Text/LibraryCoreWCF/CustomTextMessageEncoderFactory.cs
@@ -0,0 +1,24 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+namespace CoreWcf.Samples.CustomTextMessageEncoder
+{
+ public class CustomTextMessageEncoderFactory : MessageEncoderFactory
+ {
+ internal CustomTextMessageEncoderFactory(string mediaType, string charSet, MessageVersion version)
+ {
+ MessageVersion = version;
+ MediaType = mediaType;
+ CharSet = charSet;
+ Encoder = new CustomTextMessageEncoder(this);
+ }
+
+ public override MessageEncoder Encoder { get; }
+
+ public override MessageVersion MessageVersion { get; }
+
+ internal string MediaType { get; }
+
+ internal string CharSet { get; }
+ }
+}
diff --git a/Extensibility/MessageEncoder/Text/LibraryCoreWCF/CustomTextMessageEncoder_CoreWCF.csproj b/Extensibility/MessageEncoder/Text/LibraryCoreWCF/CustomTextMessageEncoder_CoreWCF.csproj
new file mode 100644
index 0000000..b673db7
--- /dev/null
+++ b/Extensibility/MessageEncoder/Text/LibraryCoreWCF/CustomTextMessageEncoder_CoreWCF.csproj
@@ -0,0 +1,21 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Extensibility/MessageEncoder/Text/LibraryCoreWCF/CustomTextMessageEncodingBindingElement.cs b/Extensibility/MessageEncoder/Text/LibraryCoreWCF/CustomTextMessageEncodingBindingElement.cs
new file mode 100644
index 0000000..b3a1fba
--- /dev/null
+++ b/Extensibility/MessageEncoder/Text/LibraryCoreWCF/CustomTextMessageEncodingBindingElement.cs
@@ -0,0 +1,125 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System.Xml;
+
+namespace CoreWcf.Samples.CustomTextMessageEncoder
+{
+ public class CustomTextMessageBindingElement : MessageEncodingBindingElement, IWsdlExportExtension
+ {
+ private MessageVersion _msgVersion;
+ private string _mediaType;
+ private string _encoding;
+ private readonly XmlDictionaryReaderQuotas _readerQuotas;
+
+ private CustomTextMessageBindingElement(CustomTextMessageBindingElement binding)
+ : this(binding.Encoding, binding.MediaType, binding.MessageVersion)
+ {
+ _readerQuotas = new XmlDictionaryReaderQuotas();
+ binding.ReaderQuotas.CopyTo(_readerQuotas);
+ }
+
+ public CustomTextMessageBindingElement(string encoding, string mediaType, MessageVersion msgVersion)
+ {
+ _msgVersion = msgVersion ?? throw new ArgumentNullException(nameof(msgVersion));
+ _mediaType = mediaType ?? throw new ArgumentNullException(nameof(mediaType));
+ _encoding = encoding ?? throw new ArgumentNullException(nameof(encoding));
+ _readerQuotas = new XmlDictionaryReaderQuotas();
+ }
+
+ public CustomTextMessageBindingElement(string encoding, string mediaType)
+ : this(encoding, mediaType, MessageVersion.Soap11WSAddressing10)
+ {
+ }
+
+ public CustomTextMessageBindingElement(string encoding)
+ : this(encoding, "text/xml")
+ {
+ }
+
+ public CustomTextMessageBindingElement()
+ : this("UTF-8")
+ {
+ }
+
+ public override MessageVersion MessageVersion
+ {
+ get
+ {
+ return _msgVersion;
+ }
+
+ set
+ {
+ _msgVersion = value ?? throw new ArgumentNullException(nameof(value));
+ }
+ }
+
+ public string MediaType
+ {
+ get
+ {
+ return _mediaType;
+ }
+
+ set
+ {
+ _mediaType = value ?? throw new ArgumentNullException(nameof(value));
+ }
+ }
+
+ public string Encoding
+ {
+ get
+ {
+ return _encoding;
+ }
+
+ set
+ {
+ _encoding = value ?? throw new ArgumentNullException(nameof(value));
+ }
+ }
+
+ // This encoder does not enforces any quotas for the unsecure messages. The
+ // quotas are enforced for the secure portions of messages when this encoder
+ // is used in a binding that is configured with security.
+ public XmlDictionaryReaderQuotas ReaderQuotas => _readerQuotas;
+
+ #region IMessageEncodingBindingElement Members
+
+ public override MessageEncoderFactory CreateMessageEncoderFactory() => new CustomTextMessageEncoderFactory(MediaType, Encoding, MessageVersion);
+
+ #endregion
+
+ public override BindingElement Clone() => new CustomTextMessageBindingElement(this);
+
+ public override T GetProperty(BindingContext context)
+ {
+ if (typeof(T) == typeof(XmlDictionaryReaderQuotas))
+ {
+ return (T)(object)_readerQuotas;
+ }
+ else
+ {
+ return base.GetProperty(context);
+ }
+ }
+
+ #region IWsdlExportExtension Members
+
+ void IWsdlExportExtension.ExportContract(WsdlExporter exporter, WsdlContractConversionContext context)
+ {
+ }
+
+ void IWsdlExportExtension.ExportEndpoint(WsdlExporter exporter, WsdlEndpointConversionContext context)
+ {
+ // The MessageEncodingBindingElement is responsible for ensuring that the WSDL has the correct
+ // SOAP version. We can delegate to the WCF implementation of TextMessageEncodingBindingElement for this.
+ TextMessageEncodingBindingElement mebe = new TextMessageEncodingBindingElement();
+ mebe.MessageVersion = _msgVersion;
+ ((IWsdlExportExtension)mebe).ExportEndpoint(exporter, context);
+ }
+ #endregion
+ }
+}
diff --git a/Extensibility/MessageEncoder/Text/LibraryCoreWCF/CustomTextMessageEncodingBindingSection.cs b/Extensibility/MessageEncoder/Text/LibraryCoreWCF/CustomTextMessageEncodingBindingSection.cs
new file mode 100644
index 0000000..b180dc8
--- /dev/null
+++ b/Extensibility/MessageEncoder/Text/LibraryCoreWCF/CustomTextMessageEncodingBindingSection.cs
@@ -0,0 +1,116 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System.ComponentModel;
+using System.Configuration;
+using System.Xml;
+
+namespace CoreWcf.Samples.CustomTextMessageEncoder
+{
+ public class CustomTextMessageEncodingElement : BindingElementExtensionElement
+ {
+ public CustomTextMessageEncodingElement()
+ {
+ }
+
+ public override void ApplyConfiguration(BindingElement bindingElement)
+ {
+ base.ApplyConfiguration(bindingElement);
+ CustomTextMessageBindingElement binding = (CustomTextMessageBindingElement)bindingElement;
+ binding.MessageVersion = MessageVersion;
+ binding.MediaType = MediaType;
+ binding.Encoding = Encoding;
+ ApplyConfiguration(binding.ReaderQuotas);
+ }
+
+ private void ApplyConfiguration(XmlDictionaryReaderQuotas readerQuotas)
+ {
+ if (readerQuotas == null)
+ throw new ArgumentNullException(nameof(readerQuotas));
+
+ if (ReaderQuotasElement.MaxDepth != 0)
+ {
+ readerQuotas.MaxDepth = ReaderQuotasElement.MaxDepth;
+ }
+ if (ReaderQuotasElement.MaxStringContentLength != 0)
+ {
+ readerQuotas.MaxStringContentLength = ReaderQuotasElement.MaxStringContentLength;
+ }
+ if (ReaderQuotasElement.MaxArrayLength != 0)
+ {
+ readerQuotas.MaxArrayLength = ReaderQuotasElement.MaxArrayLength;
+ }
+ if (ReaderQuotasElement.MaxBytesPerRead != 0)
+ {
+ readerQuotas.MaxBytesPerRead = ReaderQuotasElement.MaxBytesPerRead;
+ }
+ if (ReaderQuotasElement.MaxNameTableCharCount != 0)
+ {
+ readerQuotas.MaxNameTableCharCount = ReaderQuotasElement.MaxNameTableCharCount;
+ }
+ }
+
+ public override Type BindingElementType => typeof(CustomTextMessageBindingElement);
+
+ protected override BindingElement CreateBindingElement()
+ {
+ CustomTextMessageBindingElement binding = new CustomTextMessageBindingElement();
+ ApplyConfiguration(binding);
+ return binding;
+ }
+
+ [ConfigurationProperty(ConfigurationStrings.MessageVersion,
+ DefaultValue = ConfigurationStrings.DefaultMessageVersion)]
+ [TypeConverter(typeof(MessageVersionConverter))]
+ public MessageVersion MessageVersion
+ {
+ get
+ {
+ return (MessageVersion)base[ConfigurationStrings.MessageVersion];
+ }
+ set
+ {
+ base[ConfigurationStrings.MessageVersion] = value;
+ }
+ }
+
+ [ConfigurationProperty(ConfigurationStrings.MediaType,
+ DefaultValue = ConfigurationStrings.DefaultMediaType)]
+ public string MediaType
+ {
+ get
+ {
+ return (string)base[ConfigurationStrings.MediaType];
+ }
+
+ set
+ {
+ base[ConfigurationStrings.MediaType] = value;
+ }
+ }
+
+ [ConfigurationProperty(ConfigurationStrings.Encoding,
+ DefaultValue = ConfigurationStrings.DefaultEncoding)]
+ public string Encoding
+ {
+ get
+ {
+ return (string)base[ConfigurationStrings.Encoding];
+ }
+
+ set
+ {
+ base[ConfigurationStrings.Encoding] = value;
+ }
+ }
+
+ [ConfigurationProperty(ConfigurationStrings.ReaderQuotas)]
+ public XmlDictionaryReaderQuotasElement ReaderQuotasElement
+ {
+ get
+ {
+ return (XmlDictionaryReaderQuotasElement)base[ConfigurationStrings.ReaderQuotas];
+ }
+ }
+ }
+}
diff --git a/Extensibility/MessageEncoder/Text/LibraryCoreWCF/MessageVersionConverter.cs b/Extensibility/MessageEncoder/Text/LibraryCoreWCF/MessageVersionConverter.cs
new file mode 100644
index 0000000..4084d09
--- /dev/null
+++ b/Extensibility/MessageEncoder/Text/LibraryCoreWCF/MessageVersionConverter.cs
@@ -0,0 +1,118 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System.ComponentModel;
+using System.ComponentModel.Design.Serialization;
+
+namespace CoreWcf.Samples.CustomTextMessageEncoder
+{
+ class MessageVersionConverter : TypeConverter
+ {
+ public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
+ {
+ if (typeof(string) == sourceType)
+ {
+ return true;
+ }
+ return base.CanConvertFrom(context, sourceType);
+ }
+
+ public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
+ {
+ if (typeof(InstanceDescriptor) == destinationType)
+ {
+ return true;
+ }
+ return base.CanConvertTo(context, destinationType);
+ }
+
+ public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
+ {
+ if (value is string)
+ {
+ string messageVersion = (string)value;
+ MessageVersion retval = null;
+ switch (messageVersion)
+ {
+ case ConfigurationStrings.Soap11WSAddressing10:
+ retval = MessageVersion.Soap11WSAddressing10;
+ break;
+ case ConfigurationStrings.Soap12WSAddressing10:
+ retval = MessageVersion.Soap12WSAddressing10;
+ break;
+ case ConfigurationStrings.Soap11WSAddressingAugust2004:
+ retval = MessageVersion.Soap11WSAddressingAugust2004;
+ break;
+ case ConfigurationStrings.Soap12WSAddressingAugust2004:
+ retval = MessageVersion.Soap12WSAddressingAugust2004;
+ break;
+ case ConfigurationStrings.Soap11:
+ retval = MessageVersion.Soap11;
+ break;
+ case ConfigurationStrings.Soap12:
+ retval = MessageVersion.Soap12;
+ break;
+ case ConfigurationStrings.None:
+ retval = MessageVersion.None;
+ break;
+ case ConfigurationStrings.Default:
+ retval = MessageVersion.Default;
+ break;
+ default:
+ throw new ArgumentOutOfRangeException("messageVersion");
+ }
+
+ return retval;
+ }
+
+ return base.ConvertFrom(context, culture, value);
+ }
+
+ public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
+ {
+ if (typeof(string) == destinationType && value is MessageVersion)
+ {
+ string retval = null;
+ MessageVersion messageVersion = (MessageVersion)value;
+ if (messageVersion == MessageVersion.Default)
+ {
+ retval = ConfigurationStrings.Default;
+ }
+ else if (messageVersion == MessageVersion.Soap11WSAddressing10)
+ {
+ retval = ConfigurationStrings.Soap11WSAddressing10;
+ }
+ else if (messageVersion == MessageVersion.Soap12WSAddressing10)
+ {
+ retval = ConfigurationStrings.Soap12WSAddressing10;
+ }
+ else if (messageVersion == MessageVersion.Soap11WSAddressingAugust2004)
+ {
+ retval = ConfigurationStrings.Soap11WSAddressingAugust2004;
+ }
+ else if (messageVersion == MessageVersion.Soap12WSAddressingAugust2004)
+ {
+ retval = ConfigurationStrings.Soap12WSAddressingAugust2004;
+ }
+ else if (messageVersion == MessageVersion.Soap11)
+ {
+ retval = ConfigurationStrings.Soap11;
+ }
+ else if (messageVersion == MessageVersion.Soap12)
+ {
+ retval = ConfigurationStrings.Soap12;
+ }
+ else if (messageVersion == MessageVersion.None)
+ {
+ retval = ConfigurationStrings.None;
+ }
+ else
+ {
+ throw new ArgumentOutOfRangeException("messageVersion");
+ }
+ return retval;
+ }
+ return base.ConvertTo(context, culture, value, destinationType);
+ }
+ }
+}
diff --git a/Extensibility/MessageEncoder/Text/Service/CalculatorService.cs b/Extensibility/MessageEncoder/Text/Service/CalculatorService.cs
new file mode 100644
index 0000000..fe26abf
--- /dev/null
+++ b/Extensibility/MessageEncoder/Text/Service/CalculatorService.cs
@@ -0,0 +1,29 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+namespace CoreWcf.Samples.TextMessageEncoder
+{
+ // Service class which implements the service contract interface.
+ public class CalculatorService : ICalculatorService
+ {
+ public double Add(double n1, double n2)
+ {
+ return n1 + n2;
+ }
+
+ public double Subtract(double n1, double n2)
+ {
+ return n1 - n2;
+ }
+
+ public double Multiply(double n1, double n2)
+ {
+ return n1 * n2;
+ }
+
+ public double Divide(double n1, double n2)
+ {
+ return n1 / n2;
+ }
+ }
+}
diff --git a/Extensibility/MessageEncoder/Text/Service/ICalculatorService.cs b/Extensibility/MessageEncoder/Text/Service/ICalculatorService.cs
new file mode 100644
index 0000000..8ce64a4
--- /dev/null
+++ b/Extensibility/MessageEncoder/Text/Service/ICalculatorService.cs
@@ -0,0 +1,19 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+namespace CoreWcf.Samples.TextMessageEncoder
+{
+ // Define a service contract.
+ [ServiceContract]
+ public interface ICalculatorService
+ {
+ [OperationContract]
+ double Add(double n1, double n2);
+ [OperationContract]
+ double Subtract(double n1, double n2);
+ [OperationContract]
+ double Multiply(double n1, double n2);
+ [OperationContract]
+ double Divide(double n1, double n2);
+ }
+}
diff --git a/Extensibility/MessageEncoder/Text/Service/Program.cs b/Extensibility/MessageEncoder/Text/Service/Program.cs
new file mode 100644
index 0000000..04bed00
--- /dev/null
+++ b/Extensibility/MessageEncoder/Text/Service/Program.cs
@@ -0,0 +1,39 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+var builder = WebApplication.CreateBuilder();
+builder.WebHost.UseKestrel(options =>
+{
+ options.AllowSynchronousIO = true;
+});
+
+//Enable CoreWCF Services, with metadata (WSDL) support
+builder.Services.AddServiceModelServices()
+ .AddServiceModelMetadata()
+ .AddSingleton();
+
+var app = builder.Build();
+
+app.UseServiceModel(builder =>
+{
+ // Add the Calculator Service
+ builder.AddService(serviceOptions => { });
+
+ BasicHttpBinding basicHttpBinding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
+ HttpTransportBindingElement httpTransportBindingElement = basicHttpBinding.CreateBindingElements().Find();
+ MessageEncodingBindingElement encodingBindingElement = new CustomTextMessageBindingElement("UTF-8", "application/soap+xml", MessageVersion.Soap12WSAddressing10);
+ httpTransportBindingElement.TransferMode = TransferMode.Streamed;
+ CustomBinding binding = new CustomBinding(new BindingElement[]
+ {
+ encodingBindingElement,
+ httpTransportBindingElement
+ });
+
+ builder.AddServiceEndpoint(binding, "CalculatorService");
+
+ // Configure WSDL to be available
+ var serviceMetadataBehavior = app.Services.GetRequiredService();
+ serviceMetadataBehavior.HttpsGetEnabled = true;
+});
+
+app.Run();
diff --git a/Extensibility/MessageEncoder/Text/Service/Properties/launchSettings.json b/Extensibility/MessageEncoder/Text/Service/Properties/launchSettings.json
new file mode 100644
index 0000000..b210dc7
--- /dev/null
+++ b/Extensibility/MessageEncoder/Text/Service/Properties/launchSettings.json
@@ -0,0 +1,28 @@
+{
+ "iisSettings": {
+ "windowsAuthentication": false,
+ "anonymousAuthentication": true,
+ "iisExpress": {
+ "applicationUrl": "http://localhost:57035/CalculatorService",
+ "sslPort": 44315
+ }
+ },
+ "profiles": {
+ "Service": {
+ "commandName": "Project",
+ "dotnetRunMessages": true,
+ "launchBrowser": true,
+ "launchUrl": "https://localhost:5001/CalculatorService",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ },
+ "IIS Express": {
+ "commandName": "IISExpress",
+ "launchBrowser": true,
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ }
+ }
+}
diff --git a/Extensibility/MessageEncoder/Text/Service/Service.csproj b/Extensibility/MessageEncoder/Text/Service/Service.csproj
new file mode 100644
index 0000000..47dce29
--- /dev/null
+++ b/Extensibility/MessageEncoder/Text/Service/Service.csproj
@@ -0,0 +1,27 @@
+
+
+
+ net6.0
+ enable
+ true
+ InProcess
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Extensibility/MessageEncoder/Text/Service/appsettings.Development.json b/Extensibility/MessageEncoder/Text/Service/appsettings.Development.json
new file mode 100644
index 0000000..0c208ae
--- /dev/null
+++ b/Extensibility/MessageEncoder/Text/Service/appsettings.Development.json
@@ -0,0 +1,8 @@
+{
+ "Logging": {
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft.AspNetCore": "Warning"
+ }
+ }
+}
diff --git a/Extensibility/MessageEncoder/Text/Service/appsettings.json b/Extensibility/MessageEncoder/Text/Service/appsettings.json
new file mode 100644
index 0000000..10f68b8
--- /dev/null
+++ b/Extensibility/MessageEncoder/Text/Service/appsettings.json
@@ -0,0 +1,9 @@
+{
+ "Logging": {
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft.AspNetCore": "Warning"
+ }
+ },
+ "AllowedHosts": "*"
+}