WCF-EF5 - Error due to the service endpoint binding not using the HTTP protocol or HTTP request context being aborted by the server

I am using Entity Framework 5 and WCF data service.

I have the following method in the service1.cs

 public IList<Employee> GetEmployee()
        {
            using (ChinookEntities DBEntities = new ChinookEntities()) { 

            IList<Employee> ListOfEmployees = (IList<Employee>)(DBEntities.Employees.ToList());
            return ListOfEmployees.ToList();
        }

Open in new window

When I debug through WCF test client I am able to get the list of employees in the above IList<> ListOfEmployees, however after the method executes in the WCF Test client it gives the following error:

An error occurred while receiving the HTTP response to http://localhost:8733/Design_Time_Addresses/ChinookWCF/Service1/. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down).

Just for information I have another method GetData and that works fine from WCF test client and able to invoke the method.

public string GetData(int value)
        {
            return string.Format("You entered: {0}", value);
        }

Open in new window

Am I missing something.

Thanks in advance.
ExplorerJKAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

it_saigeDeveloperCommented:
With only a partial view of service1.cs (and any other dependencies), we can only *guess* as to the problem and it's solution.

In order for WCF to work, you have to specify the following three things (Address, Binding and Contract).  It looks like you have the address (where to connect) and the binding (what to connect with).  Perhaps you are missing the contract for the GetEmployee method.

Perhaps some more clarification as to the make-up of your project is in order.

-saige-
ExplorerJKAuthor Commented:
Hi Saige,

Thanks Saige for the reply and Sorry for the delay, Operation contract is present, the issue seems to be in serialization as I said when I debug the data is returned in the ListOfEmployees, it give error when it returns the response of collection to the wire, If I create a new POCO class other than the one created by EF and pass that new POCO class with the ListOfEmployee, will  that pass through WCF test client.

Let me know how we can pass collection (IList<T>)  through WCF as in the above scenario, I will try a different approach in meantime.

Thanks.
it_saigeDeveloperCommented:
Well since a generic List is already a serializable object, you will want to start by ensuring that the Employee object is serializable as well.

-saige-

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
WCF

From novice to tech pro — start learning today.