Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml WCF web服务和ASMX生成的模式不同_Xml_Wcf_Web Services_Xsd_Schema - Fatal编程技术网

Xml WCF web服务和ASMX生成的模式不同

Xml WCF web服务和ASMX生成的模式不同,xml,wcf,web-services,xsd,schema,Xml,Wcf,Web Services,Xsd,Schema,我有以下课程 [Serializable()] [XmlType(AnonymousType=true)][XmlRoot(Namespace="", IsNullable=false)] public class Test { [XmlAttribute()] public string Prop { get; set; } public string Another { get; set; } } 我在WCF web服务(SVC)和ASMX w

我有以下课程

[Serializable()]  
[XmlType(AnonymousType=true)][XmlRoot(Namespace="", IsNullable=false)]  
public class Test  
{  
   [XmlAttribute()]  
   public string Prop { get; set; }  

   public string Another { get; set; }  
}
我在WCF web服务(SVC)和ASMX web服务中都使用了这个类,我希望得到一个SOAP主体,它对于ASMX和SVC都是一致的,其中“Prop”属性是一个属性。此外,我还尝试向SVC和ASMX添加服务和web引用,以下是XSD的外观:

  • 对SVC的服务引用:未为Test.Prop属性创建XmlAttribute属性
  • 对ASMX的服务引用:为Test.Prop属性创建了XmlAttribute属性
  • 对SVC的Web引用:为Test.Prop属性创建了XmlElement
  • 对ASMX的Web引用:为Test.Prop属性创建了XmlAttribute属性

  • 我的问题是,为什么生成的XSD和SOAPXMLS没有组成?我知道这并不重要,因为无论生成的模式如何,这两种方法都可以工作。

    WCF默认使用DataContract序列化程序,这与ASMX使用的XmlSerializer不同。因此,生成的XSD也会有所不同-DataCOntract序列化程序不支持XML属性(出于速度原因)

    查看Dan Rigsby的精彩文章和Aaron Skonnard的MSDN杂志文章,了解更多详细信息