NET Web服务=代理对无效

编程入门 行业动态 更新时间:2024-10-28 09:27:26
本文介绍了NET Web服务=代理对无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

调用Web服务时,遇到了以下抛出的错误。用Google搜索没有其他任何结果的话,人问同样的问题。

服务器无法处理请求。 --->该代理对(0xD860,0x27)是无效的。高代理字符(0xD800 - 0xDBFF)必须始终搭配低代理角色。(0xDC00 - 0xDFFF)} System.Exception的{System.Web.Services.Protocols.SoapException

通过运行视图,并打开一个数据集,并读取数据并返回它作为格式化的XML Web服务返回一系列从视图简单的文本字段。

修改

之所以能够这样使用下面的正则表达式剥离了不良字符,碰巧的MSWord / Excel中的字符来解决

字符串重= @[^ \ X09 \ X0A \ X0D \ x20- \ xD7FF \ xE000- \ xFFFD \ 10000倍,x10FFFF]; 返回Regex.Replace(文字,重,的String.Empty);

解决方案

可能发生的事是:

  • 在XML文件中包含的字节ED A1 A0 27. chardet的,这是最有可能的意图是эба连接codeD在IBM866。
  • 但它缺乏一个编码声明,因此解析器假定它是UTF-8。
  • 在文本得到德codeD插入UTF-16字符串D860 0027。
  • 在此字符串是不是因为配对的替代D860的有效的UTF-16,所以你得到的异常。

Getting the following thrown error when calling a web service. Have googled without any results other then people asking the same question.

Server was unable to process request. ---> The surrogate pair (0xD860, 0x27) is invalid. A high surrogate character (0xD800 - 0xDBFF) must always be paired with a low surrogate character (0xDC00 - 0xDFFF)."} System.Exception {System.Web.Services.Protocols.SoapException

The web service returns a series of simple text fields from a view by running the view and opening a dataset and reading in the data and returning it as formatted XML.

EDIT

Was able to resolve this using the following regex which strips out the bad characters which happened to be MSWord/Excel characters

string re = @"[^\x09\x0A\x0D\x20-\xD7FF\xE000-\xFFFD\x10000-x10FFFF]"; return Regex.Replace(text, re, string.Empty);

解决方案

What might be happening is that:

  • The XML file contains the bytes ED A1 A0 27. According to chardet, this was most likely intended to be эба' encoded in IBM866.
  • But it lacks an encoding declaration, so the parser assumes that it's UTF-8.
  • The text gets decoded into the UTF-16 string D860 0027.
  • This string is not valid UTF-16 because of the unpaired surrogate D860, so you get the exception.

更多推荐

NET Web服务=代理对无效

本文发布于:2023-11-14 18:50:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1588260.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:NET   Web

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!