Web 服务响应中的空字符导致 XML 文档错误

发布于 2024-07-12 00:36:14 字数 561 浏览 5 评论 0原文

SQL Server Integration Services 2005 中似乎存在一个错误,在某些情况下,该错误会将零长度字符串转换为单个字符串,该字符串的字符恰好是 ansi null,即。 ascii 字符零(请注意,这与 sql null 有很大不同)。

这种情况发生在我们的数据加载过程之一中,因此应该为空的地址行会在其中获取这些字符。

我们通过 Web 服务公开这些数据,并且数据序列化正常。 当通过 IE 查看 Web 服务响应时,空值甚至会被标准 XSL 删除,但是当您查看源代码时,您可以看到它们:

Addr2="�"

但是当您从 .Net 生成的代理调用此服务时,您会收到错误:

"There is an error in XML document"

这大概是因为null 终止文档并因此使其无效。

尽管我们可以尽力阻止这些值进入数据库,但是当这些值出现在响应中时,有什么方法可以防止代理代码出错吗? 我们并不是真的想向所有 Web 方法添加代码来检测和删除它们。

It seems there is a bug in SQL Server Integration Services 2005 which, in certain circumstances, converts a zero length string into a single character string whose character happens to be an ansi null, ie. ascii character zero (Please note that this is very different from a sql null).

This happens to one of our data load processes so that address lines which should be empty get these characters in them.

We expose this data via web services and the data serialises ok. The nulls even get stripped by the standard XSL when the web service response is viewed via IE however when you view source you can see them:

Addr2="�"

But when you call this service from a .Net generated proxy you get an error:

"There is an error in XML document"

This is presumably because the null terminates the document and therefore invalidates it.

Though we can try our best to prevent these getting into the database, is there any way to prevent the proxy code from erroring when these values are in the response? We do not really want to add code to all our web methods to detect and remove these.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

又怨 2024-07-19 00:36:14

我也遇到了类似的问题,尽管它发生在我们自己的网络服务中。 为了诊断问题,我调试了生成的 XmlSerializer DLL。 您可以通过添加

<system.diagnostics>
  <switches>
    <add name="XmlSerialization.Compilation" value="4"/>
  </switches>
</system.diagnostics>

See MSDN 文章了解详细信息。

我们能够在网络服务端修复该问题。

另一个解决方案可以在 此位置

I had a similar problem, although it happened in our own web service. To diagnose the problem I debugged the generated XmlSerializer DLL's. You can do that by adding

<system.diagnostics>
  <switches>
    <add name="XmlSerialization.Compilation" value="4"/>
  </switches>
</system.diagnostics>

See MSDN article for details.

We were able to fix the problem at the web service side.

Another solution may be found at this location.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文