标签:pre serialize 属性 roo color XML double 错误 public
情况是SingleRoom和DoubleRoom是Room类的子类。在WebService中有一个方法是返回Room类。
public Room Get(int roomId) { return Room.Get(roomId); }
XmlSerializer在序列化时只能识别父类,而不能识别子类,所以导致序列化的错误。需要将[XmlInclude(typeof(SingleRoom))]和[XmlInclude(typeof(DoubleRoom))]同时加到WebService中。
[XmlInclude(typeof(SingleHouse))] [XmlInclude(typeof(DoubleHouse))] public class RoomService : System.Web.Services.WebService
WebService生成XML文档时出错。不应是类型XXXX。使用XmlInclude或SoapInclude属性静态指定非已知的类型。
标签:pre serialize 属性 roo color XML double 错误 public
原文地址:https://www.cnblogs.com/chenh/p/10295999.html