生成REST合同对象 [英] Generate Contracts for REST objects

查看:146
本文介绍了生成REST合同对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来休息,这听起来像它应该是非常简单的。在.NET应用程序,我可以创建一个WCF服务的引用,并为所有可用的类型会为我而产生的合同。

I'm new to REST and this sounds like it should be pretty simple. In a .NET app, I can create a reference to a WCF service and the contracts for all the available types will be generated for me.

现在我想消耗在Windows Phone 7应用REST服务。虽然我可以让我的电话,并取回适当的反应,有一个简单的方法来创建每个对象将被反序列化的类?

Now I'm trying to consume a REST service in a Windows Phone 7 app. While I can make my call and get back the proper response, is there a simple way to create the classes that each object would be deserialized to?

我使用RestSharp来管理我的电话。在一些例子中我已经看到了,用户已经创建了自己的类,手动生成的XML。我想,如果在所有可能避免这一点。

I'm using RestSharp to manage my calls. In some examples I've seen, user's have created their own classes, and generated the xml manually. I would like to avoid this if at all possible.

非常感谢!

推荐答案

假设你的反应是XML,可以保存XML到一个文件中,然后调用XSD.EXE它来生成模式。呼叫XSD.EXE上的架构,它会生成一个C#类文件,您可以seriazlize,并从XML反序列化到。这里有XSD.EXE如何工作documeantion:

Assuming your response is XML, you can save the xml into a file, then call xsd.exe on it to generate a schema. Call xsd.exe on the schema and it will generate a c# class file you can seriazlize and deserialize to from the xml. Here's the documeantion on how XSD.exe works:

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

这篇关于生成REST合同对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆