0

My friend and I just created a WCF data service and would like to consume it with a Windows Phone 8 client. For the WCF data service part, the OData is proved to work with a windows form project which an do CRUD for the database.

So to get WP8 consume WCF Data Service, we followed the tutorial step by step and downloaded the sample code on the MSDN tutorial http://msdn.microsoft.com/en-us/library/windows/apps/hh394007(v=vs.105).aspx

However,the examples don't work.There's no display of data from database on the phone.

We find the Customers.LoadAsync(Query) under function public void LoadData in MainViewModel Class doesn't load the XML data in :http://services.odata.org/Northwind/Northwind.svc/Customers().

public void LoadData()
        {
            // Instantiate the context and binding collection.
            _context = new NorthwindEntities(_rootUri);
            Customers = new DataServiceCollection<Customer>(_context);

            // Specify an OData query that returns all customers.
            var query = from cust in _context.Customers
                        select cust;

            // Load the customer data.
            Customers.LoadAsync(query);
        }

We modified the function OnCustomerLoaded to display the error message if there's any:

private void OnCustomersLoaded(object sender, LoadCompletedEventArgs e)
        {
            if (e.Error != null)
            {

                MessageBox.Show(e.Error.Message+e.Error.InnerException);

            }
            // Make sure that we load all pages of the Customers feed.
            if (Staffs.Continuation != null)
            {
                Staffs.LoadNextPartialSetAsync();
            }
            //MessageBox.Show(Staffs.ToString());
            IsDataLoaded = true;
        }

We get the following error:

Error from LoadAsync method

We are using VS2012 premium, created Windows Phone 8 with data bind project, using OData 5.0.0.

We have to admit that this error may not be the root cause of the problem, but we can't figure it out since we are new to it. We appreciate if anyone can point out what shall we change to make the example work if this is not the error root.

Thanks so much!!

Wendy Lin
  • 65
  • 6
  • If you have a `NotFound` error, chances are there is a failure when serializing the data. Try updating your service reference. A good way to find out what's wrong is to enable svc trace logging on the server. – Silvermind Oct 18 '14 at 10:31

1 Answers1

0

This looks like your app does not have access to the internet, it probably caused by setting issue of your WP Emulator.

You can first try the built-in internet explorer, and check whether it has internet access. If not, you can go to the Hyper-V configuration page, and try change the network adapter settings, or refer to the following page for detail.

Karata
  • 1,079
  • 8
  • 16