0
我无法理解如何使用DataContractSerializer的在WCF RESTWCF DataContractSerializer的反序列化方向
我使用一个通道工厂,像这样:
Uri uri = new Uri("http://localhost:50000/people");
WebChannelFactory<IPersonService> chFactory = new WebChannelFactory<IPersonService>(uri);
IPersonService iPerson = chFactory.CreateChannel();
比可以从通道直接调用通道的方法这样
List<Person> allPeople = new List<Person>();
allPeople = iPerson.getAll();
这有什么,我走到这一步,如何使用DataContractSerializer的,所以我可以输出响应
MemoryStream stream = new MemoryStream();
<--------------- how to i read iPerson.getAll() into stream? --------->
XmlDictionaryReader reader = XmlDictionaryReader.CreateTextReader(stream, new XmlDictionaryReaderQuotas());
DataContractSerializer dcs = new DataContractSerializer(typeof(Person));
List<Person> allpeople2 = (List<Person>)dcs.ReadObject(reader, true);
reader.Close();
stream.Close();
我不完全确定如何将这些碎片放在一起,以使其一切工作。