Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

I'm trying to consume a RESTful web service API and use the data returned to construct an MVC3 site.

I'm not sure how best to proceed when handling the returned data. Should I manually create classes for the return data or is there a simpler/safer way?

Can anyone point me in the direction of a good tutorial?

Edit

To add some background info...

I might make a call to the API for some region information. This could result in a collection of depots being returned. Drilling down into the data, I could then request the routes associated with a depot and then request the drivers associated with the depot.

In the example above, I'll need to create objects for a region, depot and driver.

Is there a cleaver way to do this (maybe from the WSDL) or is it a typing exercise making properties for each object.

I suppose I could do with something like the entity framework to model the objects without having the database exposed to me. does such a thing exist?

share|improve this question

If your rest service is returning an XML, you may load that to an XMLDocument /XDocument and parse thru it to get the relevant details. You can do LINQ TO XML too on this to make things easier.

If it is returning JSON, You can use WebClient.DownloadString method to get the data in string format and then Deserialize that to your entities. in that case, you need those fake / proxy classes.

share|improve this answer
    
The API is capable of returning XML or JSON. I assume I only have to create a model that will deal with one case. Once I have the XML I need to convert it to objects. – TeamWild May 31 '12 at 14:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.