I am trying to connect to an external Web Service with encoding ISO-8859-1 (the web service has PHP implementation) using VS 2019, .net core 3. I add Connected Service. When create new basic http binding with encoding, i get exception with message "The text encoding 'iso-8859-1' used in the text message format is not supported. (Parameter 'encoding')".

***var binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport)
        {
            MaxReceivedMessageSize = int.MaxValue,
            MaxBufferPoolSize = int.MaxValue,
            MaxBufferSize = int.MaxValue,
            ReaderQuotas = System.Xml.XmlDictionaryReaderQuotas.Max,
            AllowCookies = true,
            TextEncoding = Encoding.GetEncoding("ISO-8859-1"),
        };***

What's my mistake?

1

There are 1 best solutions below

0
Ding Peng On

The TextMessageEncodingBindingElement of WCF supports only the UTF-8, UTF-16 and big-endian Unicode encodings. If you want to use iso-8859-1 encoding, you can consider custom message encoder. This is the reference link:

https://learn.microsoft.com/en-us/dotnet/framework/wcf/samples/custom-message-encoder-custom-text-encoder?redirectedfrom=MSDN