c# - Pass Array to a WCF function -
so, have c# project in which, loading xml document (contains name of students , id) using linq xml , have associated info (their due date, amount , stuff ) wcf service. added service right click , add together service reference , need pass arrays getdata function, initialized null obviously. cant able convert array service type , function returns array too. how assign array studentarray ?
servicereference1.serviceclient client = new servicereference1.rycorserviceclient(); application.servicereference1.student[] studentarray = new servicereference1.student[9]; student[] array = studentlist.toarray(); //for (int = 0; <= array.count(); i++) // studentarray[i] = (rycorapplication.servicereference1.student)array[i]; //this gives me error says cannot convert type 'application.student' 'application.servicereference1.student'. var info = client.getdata(studentarray);
after getting data, how save info xml file ?
you pretty much have this:
list<servicereference1.student> wcfstudentlist = new system.collections.generic.list<servicereference1.student>(); foreach (var pupil in studentlist) { wcfstudentlist.add(new servicereference1.student() { id = student.id, name = student.name, ..etc.. }); } var info = client.getstudentdata(wcfstudentlist.toarray());
i have question why don't alter wcf phone call if can take list of pupil ids instead of passing entire object though?
c# .net xml wcf
No comments:
Post a Comment