Using Domain Entity Classes in Silverlight/MVC

Topics: Web Api
Oct 24, 2011 at 7:02 AM

Suppose if we hosted the WCF web api in another server.This Web api project has reference to domain repository and Domain Entity projects.

I would like to consume the WCF web api from Silverlight/MVC controller.How to convert the response(contains domain entity like Person Class in response) from WCF  to Person Class?.How silverlight/MVC controller knows the Person Type?Do we need to add same domain entity project reference to silverlight/MVC project?

 

Coordinator
Oct 24, 2011 at 4:51 PM

You can use a tool like xsd.exe to generate serializable types from the XML schemas for your data types. From the MVC Controller you can use the HttpClient and the ReadAsXxx extension methods to then call the Web API. We don’t currently support HttpClient on Silverlight, but you could use HttpWebRequest or take a look at a community HttpClient implementation.

Daniel Roth