如何在wcf中使用DataContractSerializer反序列化嵌套的xml? 示例xml是;
<smsPaidPhoneBookSearchResponse xmlns="http://callturksvc.alfion.com.tr">
<webServiceResponseType>SUCCESS</webServiceResponseType>
<clientQueryId>112628650000001078</clientQueryId>
<phoneBookList>
<phoneBook>
<cityName>İstanbul</cityName>
<districtName>Beşiktaş</districtName>
<firstName>Şuayp</firstName>
<lastModifiedDateTime>2013-03-06T16:05:59.508+02:00</lastModifiedDateTime>
<lastName>Çiçek</lastName>
<phoneBookTypeEnumValue>TURKCELL</phoneBookTypeEnumValue>
<phoneNumberText>535357****</phoneNumberText>
</phoneBook>
<phoneBook>
<cityName>İstanbul</cityName>
<districtName>Beşiktaş</districtName>
<firstName>Şuayp</firstName>
<lastModifiedDateTime>2013-03-06T16:05:59.510+02:00</lastModifiedDateTime>
<lastName>Çiçek</lastName>
<phoneBookTypeEnumValue>TURKCELL</phoneBookTypeEnumValue>
<phoneNumberText>535957****</phoneNumberText>
</phoneBook>
</phoneBookList>
</smsPaidPhoneBookSearchResponse>
我成功获得了这些值(webServiceResponseType,clientQueryId),但我无法将phoneBookList作为phoneBook类的通用列表。例如:List<phoneBook>
任何解决方案?
答案 0 :(得分:1)
一种简单的查找方法是在C#中创建一个类似的结构,然后将其序列化。这样你就会知道xml中有什么问题。根据我的经验,您是否在合同中将phoneBookList标记为Array,然后将PhoneBook标记为具有正确名称的Array Element?