简体   繁体   English

在哪种情况下svcutil.exe决定在生成的代理代码中应用XmlSerializerFormatAttribute?

[英]In what case svcutil.exe decides to apply XmlSerializerFormatAttribute in generated proxy code?

As in title in what case svcutil.exe decides to apply XmlSerializerFormatAttribute in generated proxy code? 如标题中所示,在哪种情况下svcutil.exe决定在生成的代理代码中应用XmlSerializerFormatAttribute I can't find any documentation about that so I'd be grateful for linking some sources. 我找不到有关此内容的任何文档,因此感谢您链接某些资源。

The XmlSerializer is chosen (and the XmlSerializerFormatAttribute is applied) whenever the schema of the web service is not compatible with DataContractSerializer. 每当Web服务的架构与DataContractSerializer不兼容时,都会选择XmlSerializer(并应用XmlSerializerFormatAttribute)。 As user "Aphelion" pointed out in their answer, one case when this can happen is when using some legacy ASMX web services. 正如用户“ Aphelion”在其答案中指出的那样,可能发生这种情况的一种情况是使用某些旧式ASMX Web服务。 However, it is also quite common to see this when interoperating with non-.NET services (for example, Java-based). 但是,与非.NET服务(例如,基于Java的)进行互操作时,也经常会看到这种情况。 The definitive document here is actually http://msdn.microsoft.com/en-us/library/ms733112.aspx , which tells you exactly what is and isn't supported in the schema. 此处的权威文档实际上是http://msdn.microsoft.com/zh-cn/library/ms733112.aspx ,该文档准确地告诉您架构中支持和不支持的内容。

The XmlSerializerFormat is used to support backwards compatibility with ASMX (Classic web services). XmlSerializerFormat用于支持与ASMX(经典Web服务)的向后兼容性。

By default, the proxy will use the DataContractSerializer . 默认情况下,代理将使用DataContractSerializer If the schema elements in the WSDL document use XSD schema features that the DataContractSerializer is unable to handle, it will pick the XmlSerializer . 如果WSDL文档中的架构元素使用DataContractSerializer无法处理的XSD架构功能,它将选择XmlSerializer


I can recommend ' Learning WCF ' by Michele Leroux Bustamante for some in-depth examples. 对于一些更深入的示例,我可以推荐Michele Leroux Bustamante的“ 学习WCF ”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM