【发布时间】:2015-11-20 08:19:40
【问题描述】:
我的应用程序中有以下网络方法
[WebMethod]
public bool Test(string id)
{
return true;
}
使用 WebRequest.Create(..) 我得到以下 xml 文件
<?xml version="1.0" encoding="utf-8"?>
<boolean xmlns="http://tempuri.org/">true</boolean>
并使用以下代码
XmlSerializer ser = new XmlSerializer(typeof(bool));
var result = (bool)ser.Deserialize(responseStream);
我得到以下异常
- “XML 文档 (2, 2) 中存在错误。”
<boolean xmlns='http://tempuri.org/'> was not expected.
【问题讨论】:
-
a
XmlSerializer类型为bool在序列化时返回类似于<?xml version="1.0"?><boolean>true</boolean>的 xml。 -
我意识到了这一点,但这并不能真正帮助我反序列化从 web 服务返回的数据
-
我猜这是某种与网络服务相关的命名空间。
-
觉得我有 :) 谢谢
标签: c# xml web-services