1

I have a WCF REST SOAP web service. whenever I try to call the service using console application. I get this error message:

An unhandled exception of type 'System.Data.Services.Client.DataServiceQueryException' occurred in Microsoft.Data.Services.Client.dll

This is the line the error breaks on:

int i = 0;

        foreach(var item in items)
        {
            if (DateTime.Today.Year.ToString() == item.Year)
            {
                i++;
            }
        }

where item is of type IEnumerable<EventsItem> and I use this code to populate it with data:

  result = dataContext.Events.Where(x => x.val == true).OrderByDescending(x => x.num); 

This is the console code:

    try { 
           WCF_SOAP_REST_Service.Service client = new WCF_SOAP_REST_Service.Service();
           foreach (WCF_SOAP_REST_Service.Events item in client.GetEvents("en"))
                {
                    Console.WriteLine(item.StartDate + " " + item.EnglishTitle + " " + item.Month);
                 }
        } catch(DataServiceQueryException ex)
        {
            Console.WriteLine(ex);
}

I'm using Service Reference e.g. http://mysiteurl/_vti_bin/ListData.svc what's odd is when I tried to add this reference to the solution, it prompted me many times to enter the username and password then somehow it stopped and allowed to add it. Just wanted to add that it worked fine in the test servers but when i move to production it started giving me this error... Any help will be much appreciated.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.