【发布时间】:2016-07-04 22:11:59
【问题描述】:
我使用 System.ServiceModel System.ServiceModel.Web System.ServiceModel.Activation 命名空间编写了 Web 服务。
[XmlSerializerFormat]
[OperationContract]
[WebGet(UriTemplate = Routing.GetClientRoute, BodyStyle = WebMessageBodyStyle.Bare)]
string GetClientNameById(string Id);
我用这个类描述了数据:
[XmlRoot("ServiceXmlReply")]
public class ServiceXmlReply
{
[XmlElement]
public string Name;
}
问题在于响应,我从服务中收到。它看起来像这样:
"<?xml version=\"1.0\" encoding=\"utf-8\"?>
<string>
<ServiceXmlReply xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">
<Name>Igor<Name>
<ServiceXmlReply>
</string>"
你可以看到不应该是“字符串”标签,但它是。因此,我无法反序列化响应并获取数据。
服务器端和客户端的类相同。
【问题讨论】:
标签: c# xml deserialization