WCF Service doesn't return data RRS feed

  • Question

  • User-865174439 posted

    Hello, i want to create simple mobile add using Xamarin who use WCF Service, but i have problem with return data from database.

    Firstly i connect database with WCF and create code:


        public interface IServiceWhitewagon
            List<CompanyForView> GetCompany();


     public class ServiceWhitewagon : IServiceWhitewagon
            public ServiceWhitewagon()
       public List<CompanyForView> GetCompany()
                WhitewagonEntities db = new WhitewagonEntities();
                    (from company in db.Company
                     select new CompanyForView
                         idCompany = company.idCompany,
                         name = company.name,
                         phone = company.phone,
                         adress = company.adress


        public class CompanyForView
            public int idCompany { get; set; }
            public string name { get; set; }
            public string adress { get; set; }
            public string phone { get; set; }

    In next step i connect WCF with my app called AppMobileWhitewagon

    While connect WCF I usinghttp://localhost:54308/ and i saw all created metod in WCF. Whats more i test WCF in WCT Test Client and i see data from datatable:

    In MobileApp i have problem with show data from datatable. When in App I click on the button who should show card with data from datatable app freeze on 20 seconds and show empty card.

    My code in class who should get data

    public class CompanyDataStore : ItemDataStore<Company>
            public CompanyDataStore()
                items = zamowieniaServices.GetCompany(null).GetCompanyResult.Select(k => new Company
                    idCompany = k.idCompany,
                    name = k.name,
                    phone = k.phone,
                    adress = k.adress


    public abstract class ItemDataStore<T> : IDataStore<T>
            public List<T> items;
            public IServiceWhitewagon zamowieniaServices { get; set; }
            public ItemDataStore()
                zamowieniaServices = DependencyService.Get<ServiceReferenceWhitewagon.IServiceWhitewagon>();

    I create 3 breakpoint in app:

    App stop in first breakpoint, and when i Continue run code does not cause next breakpoint

    P.S 1

    I suppose that with my View is everythink ok, since when i change code in CompanyDataStore to this, app show data from this list

     items = new List<Company>()
                   new Company{idCompany=1,name="Klient 1"},
                   new Company{idCompany=2,name="Klient 2"},

    Sunday, December 27, 2020 4:34 PM

All replies

  • User753101303 posted


    A Xamarin forum could be better. I used Xamarin with REST but never with WCF. Try perhaps Consume a Windows Communication Foundation (WCF) Web Service - Xamarin | Microsoft Docs for a proof of concept.

    You don't have an exception or what if you start by checking how many items are returned? Also is is often suggested to keep constructors as simple as possible. Also I used ObservableCollection and used async all the way down. Seems for now you try to force all this being synchronous?

    Monday, December 28, 2020 12:10 PM