Saturday 15 February 2014

c# - Soap Serializer does not support serializing Generic Types -



c# - Soap Serializer does not support serializing Generic Types -

i have encountered error, while trying create soap message in c# class.

booking class-

public class guestdetails { public string guesttitle { get; set; } public string guestname { get; set; } public string address1 { get; set; } public string address2 { get; set; } public string address3 { get; set; } public string pincode { get; set; } public string country { get; set; } public string nationality { get; set; } public string emailid { get; set; } public string phoneno { get; set; } } public class bookingdetails { public string bookingnumber { get; set; } public string bookingdate { get; set; } public string bookedby { get; set; } public string otaid { get; set; } public string otaname { get; set; } public string bookingstatus { get; set; } public string checkindate { get; set; } public string checkintime { get; set; } public string checkoutdate { get; set; } public string checkouttime { get; set; } } public class roomingdetail { public string roomtypeid { get; set; } public string rateid { get; set; } public string noofrooms { get; set; } public string adult { get; set; } public string children { get; set; } public string noofextrabed { get; set; } public string mealplan { get; set; } } public class hotel { public string hotelid { get; set; } public guestdetails guestdetails { get; set; } public bookingdetails bookingdetails { get; set; } public list<roomingdetail> roomingdetails { get; set; } } [serializable] public class rootobject { public string accesskey { get; set; } public string channelid { get; set; } public list<hotel> hotels { get; set; } }

converting c# class soap -

rootobject r = new rootobject(); r.accesskey = ""; r.channelid = ""; r.hotels = new list<hotel>(); hotel _hotel = new hotel(); _hotel.hotelid = "3"; _hotel.guestdetails = new guestdetails(); _hotel.guestdetails.guestname = "guestname"; _hotel.guestdetails.guesttitle = "guesttitle"; _hotel.guestdetails.nationality = "nationality"; _hotel.guestdetails.phoneno = "phoneno"; _hotel.guestdetails.pincode = "pincode"; _hotel.guestdetails.address1 = "address1"; _hotel.guestdetails.address2 = "address2"; _hotel.guestdetails.address3 = "address3"; _hotel.guestdetails.country = "country"; _hotel.guestdetails.emailid = "emailid"; _hotel.roomingdetails = new list<roomingdetail>(); roomingdetail _roomingdetails = new roomingdetail(); _roomingdetails.adult = "1"; _roomingdetails.children = "2"; _roomingdetails.mealplan = "sds"; _roomingdetails.noofextrabed = ""; _roomingdetails.noofrooms = "1"; _roomingdetails.rateid = "222"; _roomingdetails.roomtypeid = "11"; _hotel.roomingdetails.add(_roomingdetails); _hotel.bookingdetails = new bookingdetails(); //bookingdetails _bookingdetails = new bookingdetails(); _hotel.bookingdetails.bookedby = "jagadees"; _hotel.bookingdetails.bookingdate = "05-08-2014"; _hotel.bookingdetails.bookingnumber = "15999"; _hotel.bookingdetails.bookingstatus = "success"; _hotel.bookingdetails.checkindate = "03-09-2014"; _hotel.bookingdetails.checkintime = ""; _hotel.bookingdetails.checkoutdate = "05-09-2014"; _hotel.bookingdetails.checkouttime = ""; _hotel.bookingdetails.otaid = ""; _hotel.bookingdetails.otaname = ""; r.hotels.add(_hotel); var r = new random(); soapformatter formatter = new soapformatter(); string mytempfile = path.combine(path.gettemppath(), r.next() + "savefile.txt"); gc.suppressfinalize(mytempfile); stream objfilestream = new filestream(mytempfile, filemode.create, fileaccess.write, fileshare.none); formatter.serialize(objfilestream, r); <-- error here --> objfilestream.close();

error -

serializationexception ungandled user code soap serializer not back upwards serializing generic types : system.collections.generic.list`1[soapwbapp.hotel].

c# generics serialization soap

No comments:

Post a Comment