有没有办法从DataContract导出XSD架构 [英] Is there a way to export an XSD schema from a DataContract

查看:150
本文介绍了有没有办法从DataContract导出XSD架构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用DataContractSerializer的序列化/反序列化我班/从XML。一切工作正常,但在某些时候,我想建立一个标准的架构独立于实际的code这些XML文件的格式。这样,如果东西坏了序列化过程中,我总是可以回去检查一下是什么标准架构应该的。或者,如果我确实需要修改架构的修改是一个明确的决定,而并非只是一个后来改变我的code的影响。

I'm using DataContractSerializer to serialize/deserialize my classes to/from XML. Everything works fine, but at some point I'd like to establish a standard schema for the format of these XML files independent of the actual code. That way if something breaks in the serialization process I can always go back and check what the standard schema should be. Or if I do need to modify the schema the modification is an explicit decision rather then just a later affect of modifying my code.

在此外,其他人可以写入基于可能不.NET,将需要从这些XML文件读取其他软件。我希望能够给他们提供某种模式的文档。

In addition, other people may be writing other software that may not be .NET based that would need to read from these XML files. I'd like to be able to provide them with some kind of documentation of the schema.

有一个DataContract和XSD架构之间的一些关系。有没有一种方法来导出类DataContract属性作为XSD架构?

Is there some relationship between a DataContract and an XSD schema. Is there a way to export the DataContract attributes in classes as an XSD schema?

推荐答案

SvcUtil工具。 EXE可以导出元数据的汇编的数据合同
有间 DataContract和XSD 关系:

Svcutil.exe can "export metadata for compiled data contracts".
There is relationship between DataContract and XSD:

DataContractSerializer的映射CLR类型为xsd时,元数据使用元数据端点或ServiceModel元数据实用工具(Svcutil.exe)Windows通讯基础(WCF)服务出口。欲了解更多信息,请参见数据协定序列化。

The DataContractSerializer maps CLR types to XSD when metadata is exported from a Windows Communication Foundation (WCF) service using a metadata endpoint or the ServiceModel Metadata Utility Tool (Svcutil.exe). For more information, see Data Contract Serializer.

DataContractSerializer的也映射XSD到CLR类型时,svcutil.exe的用于访问Web服务描述语言(WSDL)或XSD文件并生成数据服务合同或客户。

The DataContractSerializer also maps XSD to CLR types when Svcutil.exe is used to access Web Services Description Language (WSDL) or XSD documents and generate data contracts for services or clients.

您可以得到XSD(S)在运行时为好,甚至在你的浏览器中,通过的设置一个 MEX终结
默认WSDL将包含对XSD(s)表示,可以通过端点访问以及

You can get the XSD(s) at run-time as well, even in your browser, by setting up a MEX endpoint.
The WSDL by default will contain references to XSD(s) that can be accessed through the endpoint as well.

这篇关于有没有办法从DataContract导出XSD架构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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