Click here to Skip to main content
11,933,854 members (56,715 online)
Rate this:
Please Sign up or sign in to vote.
See more: WCF
Hi All

I developed the wcf rest service and i consumed in windows phone7.1
but my listbox was empty.
public List<Product> GetProducts()
            PractiseEntities db = new PractiseEntities();
            var students = from p in db.StudentEntities select p;
            List<Product> st1 = students.ToList().ConvertAll(new Converter<StudentEntity, Product>(TranslateStudentEntityToStudent1));
            return st1;
private Product TranslateStudentEntityToStudent1(StudentEntity student)
            Product p = new Product();
            p.ProductID = student.ID;
            p.ProductName = student.Name;
            p.QuantityPerUnit = student.Adress;
            p.UnitPrice = student.DOB;
            return p;

Windows Phone7.1 app:
private void btn_getdata_Click(object sender, RoutedEventArgs e)
            WebClient proxy1 = new WebClient();
            proxy1.DownloadStringCompleted += new DownloadStringCompletedEventHandler(proxy1_DownloadStringCompleted);
            proxy1.DownloadStringAsync(new Uri("http://localhost:49166/RestService.svc/Student"));
  private void proxy1_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
Stream s = new MemoryStream(Encoding.Unicode.GetBytes(e.Result));
            DataContractJsonSerializer obj = new DataContractJsonSerializer(typeof(List<Student>));
            List<Student> result = obj.ReadObject(s) as List<Student>;
            listBox2.ItemsSource = result;
ListBox Height="172" Foreground="White" FontSize="25" HorizontalAlignment="Left" Margin="20,31,0,0" Name="listBox2" VerticalAlignment="Top" Width="401" >
Posted 20-Mar-13 23:05pm
Edited 20-Mar-13 23:22pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web03 | 2.8.151126.1 | Last Updated 21 Mar 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100