Quote:Cannot serialize interface System.Collections.Generic.IEnumerable`1[[WebApplication1.ReturnValues, WebApplication1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]. cananybody help mein this issue? this is my server side code: C# <blockquote class="quote"><div class="op">Quote:</div>using System; using System.Collections; using System.Collections.Generic; using System.Data; using System.Data.Linq.SqlClient; using System.Linq; using System.Web; using System.Web.Script.Services; using System.Web.Services; using System.Xml; using System.Xml.Linq; namespace WebApplication1 { [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.ComponentModel.ToolboxItem(false)] // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. // [System.Web.Script.Services.ScriptService] public class MyWebService : System.Web.Services.WebService { [WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Xml)] public IEnumerable<ReturnValues> MyService(String vinValue) { LinqSqlDataContext db = new LinqSqlDataContext(); var reportdata = from f in db.ff from gin db.gg from h in db.hh where f.first== vinValue select new XElement("flash", new XElement("first", f.first), new XElement("second", g.second) ); var reportXml = new XElement("FlashList", reportdata); reportXml.Save("file.xml"); string uri = Uri.EscapeUriString(vinValue); string url = FormatUrl(uri); XDocument xdoc = XDocument.Load(url); IEnumerable<ReturnValues> results = from info in xdoc.Descendants("VIN") select new ReturnValues { first= info.Element("first").Value, second= info.Element("second").Value, }; return results; } string FormatUrl(string vinVal) { return "http://localhost:11936/MyWebService.asmx&VIN="+vinVal; } } } and also another class: C# namespace WebApplication1 { public class ReturnValues { public string first{ get; set; } public string second{ get; set; } } } AND in client side C# <pre lang="xml"><blockquote class="quote"><div class="op">Quote:</div>namespace FlashListByVinLadan { public partial class MainWindow : Window { string vinValue; public MainWindow() { InitializeComponent(); } private void FrameLoad_Activated(object sender, EventArgs e) { } private void btnGo_Click(object sender, RoutedEventArgs e) { localhost.MyWebService w = new localhost.MyWebService(); IEnumerable<ReturnValues> req = w.MyService(vinValue); }
<blockquote class="quote"><div class="op">Quote:</div>using System; using System.Collections; using System.Collections.Generic; using System.Data; using System.Data.Linq.SqlClient; using System.Linq; using System.Web; using System.Web.Script.Services; using System.Web.Services; using System.Xml; using System.Xml.Linq; namespace WebApplication1 { [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.ComponentModel.ToolboxItem(false)] // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. // [System.Web.Script.Services.ScriptService] public class MyWebService : System.Web.Services.WebService { [WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Xml)] public IEnumerable<ReturnValues> MyService(String vinValue) { LinqSqlDataContext db = new LinqSqlDataContext(); var reportdata = from f in db.ff from gin db.gg from h in db.hh where f.first== vinValue select new XElement("flash", new XElement("first", f.first), new XElement("second", g.second) ); var reportXml = new XElement("FlashList", reportdata); reportXml.Save("file.xml"); string uri = Uri.EscapeUriString(vinValue); string url = FormatUrl(uri); XDocument xdoc = XDocument.Load(url); IEnumerable<ReturnValues> results = from info in xdoc.Descendants("VIN") select new ReturnValues { first= info.Element("first").Value, second= info.Element("second").Value, }; return results; } string FormatUrl(string vinVal) { return "http://localhost:11936/MyWebService.asmx&VIN="+vinVal; } } }
namespace WebApplication1 { public class ReturnValues { public string first{ get; set; } public string second{ get; set; } } }
<pre lang="xml"><blockquote class="quote"><div class="op">Quote:</div>namespace FlashListByVinLadan { public partial class MainWindow : Window { string vinValue; public MainWindow() { InitializeComponent(); } private void FrameLoad_Activated(object sender, EventArgs e) { } private void btnGo_Click(object sender, RoutedEventArgs e) { localhost.MyWebService w = new localhost.MyWebService(); IEnumerable<ReturnValues> req = w.MyService(vinValue); }
XmlSerializer
List
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)