Reputation: 2075
I am new to the REST model with WCF. I downloaded the WCF Rest Service Template for .NET 4.0.
I have a project that is using the EF to retrieve a POCO entity from a database and then return that entity to the user.
The [WebGet] method executes properly and I can debug it to see the data being returned. However, it seems, when serializing the POCO object and trying to return it to the caller, the system is failing.
A couple of points here:
1. I can create a manual POCO object and return it fine. However, when it is returning a POCO object sourced from the database (using EF), the call fails upon return (the EF query work properly--the WebGet method just doesnt return it back to the caller.
2. The HTTP response code is 400 Bad Request. I don't get any other info (and no .NET exception).
3. The same behavior occurs when running in IIS or the Visual Studio web server.
How should I go about debugging this issue?
Thanks!
p.s. The WebGet method is below (and executes properly):
[WebGet(UriTemplate = "WorkInstruction")]
public WorkInstruction GetFirst()
{
using (ContentDBEntities objectContext = new ContentDBEntities("name=connString"))
{
return objectContext.WorkInstructions.First();
}
}
Upvotes: 1
Views: 4937
Reputation: 19
Useful Article of CodeProject to debug WCF REST Service.
http://www.codeproject.com/Tips/213007/Debug-WCF-REST-Service
Upvotes: 2
Reputation: 142094
Sounds like the WorkInstruction class is failing to serialize properly. Have you tried manually serializing it using the DataContractSerializer?
Upvotes: 1
Reputation: 6729
Run both client and host locally as two projects in the same VS solution, using multiple startup projects. Then you can breakpoint your REST service.
Upvotes: 0