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();
我不完全確定如何將這些碎片放在一起,以使其一切工作。