【问题标题】:.Net Core 3.1: The text encoding 'iso-8859-1' used in the text message format is not supported. (Parameter 'encoding').Net Core 3.1:不支持文本消息格式中使用的文本编码“iso-8859-1”。 (参数“编码”)
【发布时间】:2020-08-20 02:35:12
【问题描述】:

我正在尝试使用 VS 2019、.net core 3 连接到编码 ISO-8859-1 的外部 Web 服务(该 Web 服务具有 PHP 实现)。我添加了 Connected Service。当使用编码创建新的基本 http 绑定时,我收到异常消息“不支持文本消息格式中使用的文本编码 'iso-8859-1'。(参数'编码')”。

***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"),
        };***

我的错误是什么?

【问题讨论】:

    标签: wcf encoding iso-8859-1 basichttpbinding


    【解决方案1】:

    WCF 的 TextMessageEncodingBindingElement 仅支持 UTF-8、UTF-16 和大端 Unicode 编码。如果要使用 iso-8859-1 编码,可以考虑自定义消息编码器。 这是参考链接:

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

    【讨论】:

      猜你喜欢
      • 2011-05-06
      • 1970-01-01
      • 2010-09-13
      • 2011-05-12
      • 1970-01-01
      • 2011-12-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多