0
我使用System.ServiceModel System.ServiceModel.Web System.ServiceModel.Activation命名空间编写了web服务。xml反序列化<string>标记
[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>"
正如你可以看到那里不应该有“字符串”标签,但它是。正因为如此,我不能反序列化反应并获取数据。
服务器和客户端的类相同。
非常感谢您的回复。 问题是该方法返回类的字符串的XML代码。我不能将它转换为我的类型。 问题在于我的想法有额外的序列化。有谁知道如何设置它? –
我想了一次,找到了解决办法。你是完全正确的。我只是改变了我的课程,所以它返回了我的课程,而不是xml文档。它自己创建了正确的xml。 我现在很开心。谢谢!! –