Generate classes from XSD

怎甘沉沦 提交于 2019-12-09 01:23:21

问题


You are doing contract first development of web services in a SOA world.

After editing an XSD file, what is the best way to automatically (re)generate .net classes from the XSD files?


回答1:


xsd.exe will generate new classes for you.

Depending on how Visual Studio is set up, adding xsd.exe to "Properties / build events / post-build events" will force a regeneration every time you do a rebuild.




回答2:


If using .net 1.1 or 2.0, xsd.exe. If using 3.0 or 3.5, svcutil.exe. If you don't mind using non-supported code, LINQ-to-XSD (http://blogs.msdn.com/xmlteam/archive/2008/02/21/linq-to-xsd-alpha-0-2.aspx) is cool. With any tool, be aware that some schemas do not translate well to .NET classes automatically. If you find that to be the case, code the classes by hand, and implement IXmlSerializable.




回答3:


We are using WSCF - Web Services Contract First tool from Thinktecture to do web service development creating XSD schema first and then generating service interfaces using this tool. We've use this tool for last 2 years and I highly recommend it.

The same guys also started WSCF.blue project that is successor of their original tool and allows contract first development (read XSD first). WSCF.blue is targeted to support the Windows Communication Foundation (WCF).




回答4:


I have used http://xsd2code.codeplex.com/releases/view/22222 VS addin for this.



来源:https://stackoverflow.com/questions/260001/generate-classes-from-xsd

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!