Creating Contracts for REST Objects

I am new to REST and it seems like this should be pretty simple. In a .NET application, I can create a link to a WCF service, and contracts for all available types will be created for me.

Now I'm trying to use the REST service in a Windows Phone 7 application. Although I can make my call and return the correct answer, is there an easy way to create classes for which each object will be deserialized?

I use RestSharp to manage my calls. In some examples that I saw, the user created his own classes and generated the xml manually. I would like to avoid this, if at all possible.

many thanks!

+7
source share
2 answers

Assuming your answer is XML, you can save xml to a file and then call xsd.exe on it to create the schema. Call xsd.exe in the diagram and it will generate a C # class file, which you can seriazlize and deserialize from xml. Here is a question about how XSD.exe works:

http://msdn.microsoft.com/en-us/library/x6c1kb0s(v=VS.100).aspx

+8
source

You must generate classes to which your response data will be mapped (or use a dynamic deserialization scheme if you are on .NET 4), because REST does not include a schema definition system like SOAP does. RestSharp has a T4 helper to make it easy to create C # classes . This gives you about 80% of the way. If you need help, send a message to RestSharp Google Group .

+3
source

All Articles