生成的wsdl文件中未正确显示枚举值。为什么?

时间:2015-04-07 13:53:26

标签: c# wcf soap wsdl

当我打开像#34; myservice.com/myservice.svc?singleWsdl"这样的链接时,我试图找出如何生成WSDL。问题是我的代码中有语言枚举,wsdl文件中缺少一些值。如果这样:

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Hebrew = 73

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Hiri_Motu = 75

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Croatian = 76

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Haitian = 77

然后我在生成的WSDL文件中得到了这个:

<xs:enumeration value="Hebrew">
<xs:annotation>
<xs:appinfo>
<EnumerationValue xmlns="http://schemas.microsoft.com/2003/10/Serialization/">73</EnumerationValue>
</xs:appinfo>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="Hiri_Motu"/>
<xs:enumeration value="Croatian"/>
<xs:enumeration value="Haitian"/>
<xs:enumeration value="Hungarian"/>
<xs:enumeration value="Armenian"/>
<xs:enumeration value="Herero"/>
<xs:enumeration value="Interlingua"/>
<xs:enumeration value="Indonesian"/>
<xs:enumeration value="Interlingue"/>
<xs:enumeration value="Igbo"/>
<xs:enumeration value="Sichuan_Yi"/>
<xs:enumeration value="Inupiaq"/>
<xs:enumeration value="Ilocano"/>
<xs:enumeration value="Ido"/>
<xs:enumeration value="Icelandic"/>
<xs:enumeration value="Inuktitut"/>
<xs:enumeration value="Javanese"/>
<xs:enumeration value="Georgian"/>
<xs:enumeration value="Kongo"/>
<xs:enumeration value="Kikuyu"/>
<xs:enumeration value="Kuanyama"/>
<xs:enumeration value="Kazakh"/>
<xs:enumeration value="Kalaallisut"/>
<xs:enumeration value="Central_Khmer"/>
<xs:enumeration value="NA"/>
<xs:enumeration value="Kannada"/>
<xs:enumeration value="Kanuri"/>
<xs:enumeration value="Kashmiri"/>
<xs:enumeration value="Kurdish"/>
<xs:enumeration value="Komi"/>
<xs:enumeration value="Cornish"/>
<xs:enumeration value="Kirghiz"/>
<xs:enumeration value="Lao"/>
<xs:enumeration value="Latin"/>
<xs:enumeration value="Luxembourgish"/>
<xs:enumeration value="Ganda"/>
<xs:enumeration value="Limburgan"/>
<xs:enumeration value="Lingala"/>
<xs:enumeration value="Luba_Katanga">
<xs:annotation>
<xs:appinfo>
<EnumerationValue xmlns="http://schemas.microsoft.com/2003/10/Serialization/">114</EnumerationValue>
</xs:appinfo>
</xs:annotation>
</xs:enumeration>

所以很多语言都错过了他们的EnumerationValue。我能够发现这个问题是因为缺少&#34; 74&#34;值。我不希望在&#34; 73&#34;之后插入一些虚拟值或移动所有值,也许任何想法如何解决它?

PS: 这很好用:

 <System.Runtime.Serialization.EnumMemberAttribute()> _
        Hebrew = 73

        <System.Runtime.Serialization.EnumMemberAttribute()> _
        Hiri_Motu = 74

        <System.Runtime.Serialization.EnumMemberAttribute()> _
        Croatian = 75

        <System.Runtime.Serialization.EnumMemberAttribute()> _
        Haitian = 76

结果:

<xs:enumeration value="Hebrew">
<xs:annotation>
<xs:appinfo>
<EnumerationValue xmlns="http://schemas.microsoft.com/2003/10/Serialization/">73</EnumerationValue>
</xs:appinfo>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="Hiri_Motu">
<xs:annotation>
<xs:appinfo>
<EnumerationValue xmlns="http://schemas.microsoft.com/2003/10/Serialization/">74</EnumerationValue>
</xs:appinfo>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="Croatian">
<xs:annotation>
<xs:appinfo>
<EnumerationValue xmlns="http://schemas.microsoft.com/2003/10/Serialization/">75</EnumerationValue>
</xs:appinfo>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="Haitian">
<xs:annotation>
<xs:appinfo>
<EnumerationValue xmlns="http://schemas.microsoft.com/2003/10/Serialization/">76</EnumerationValue>
</xs:appinfo>
</xs:annotation>
</xs:enumeration>

完整枚举:

  <System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "3.0.0.0"),  _
     System.Runtime.Serialization.DataContractAttribute(Name:="Language",     [Namespace]:="http://schemas.datacontract.org/2004/07/Greenway.PrimeSuite.DataContracts.Person")>  _
Public Enum Language As Integer

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    LookUp = 9999

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Unknown = 0

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    English = 1

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Spanish = 2

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    French = 3

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Japanese = 4

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Chinese = 5

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Vietnamese = 6

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Russian = 7

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Arabic = 8

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Filipino = 9

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    German = 10

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Greek = 11

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Hindi = 12

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Italian = 13

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Korean = 14

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Polish = 15

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Portuguese = 16

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Other = 17

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Declined = 18

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Somali = 19

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Hmong = 20

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Lithuanian = 21

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Afrikaans = 22

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    American_Indian = 23

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Akan = 24

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Amharic = 25

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Aragonese = 26

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Assamese = 27

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Avaric = 28

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Aymara = 29

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Azerbaijani = 30

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Bashkir = 31

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Belarusian = 32

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Bulgarian = 33

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Bihari_languages = 34

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Bislama = 35

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Bambara = 36

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Bengali = 37

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Tibetan = 38

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Breton = 39

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Bosnian = 40

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Cambodian = 41

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Catalan = 42

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Chechen = 43

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Chamorro = 44

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Cantonese = 45

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Corsican = 46

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Cree = 47

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Church_Slavic = 48

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Chuvash = 49

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Welsh = 50

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Czech = 51

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Danish = 52

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Dutch = 53

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Divehi = 54

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Dzongkha = 55

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Ewe = 56

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Esperanto = 57

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Estonian = 58

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Basque = 59

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Faroese = 60

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Persian = 61

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Fulah = 62

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Finnish = 63

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Fijian = 64

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Western_Frisian = 65

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Irish = 66

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Gaelic = 67

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Galician = 68

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Guarani = 69

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Gujarati = 70

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Manx = 71

    <System.Runtime.Serialization.EnumMemberAttribute()>  _
    Hausa = 72

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Hebrew = 73

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Hiri_Motu = 75

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Croatian = 76

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Haitian = 77

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Hungarian = 78

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Armenian = 79

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Herero = 80

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Interlingua = 81

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Indonesian = 82

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Interlingue = 83

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Igbo = 84

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Sichuan_Yi = 85

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Inupiaq = 86

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Ilocano = 87

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Ido = 88

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Icelandic = 89

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Inuktitut = 90

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Javanese = 91

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Georgian = 92

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Kongo = 93

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Kikuyu = 94

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Kuanyama = 95

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Kazakh = 96

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Kalaallisut = 97

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Central_Khmer = 98

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    NA = 99

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Kannada = 100

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Kanuri = 101

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Kashmiri = 102

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Kurdish = 103

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Komi = 104

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Cornish = 105

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Kirghiz = 106

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Lao = 107

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Latin = 108

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Luxembourgish = 109

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Ganda = 110

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Limburgan = 111

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Lingala = 112

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Luba_Katanga = 114

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Latvian = 115

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Mandarin = 116

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Malagasy = 117

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Marshallese = 118

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Mien = 119

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Macedonian = 120

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Malayalam = 121

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Mongolian = 122

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Marathi = 123

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Maori = 124

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Malay = 125

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Maltese = 126

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Burmese = 127

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Nauru = 128

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Norwegian_Bokmål = 129

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Ndebele_North = 130

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Nepali = 131

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Ndonga = 132

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Norwegian_Nynorsk = 133

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Norwegian = 134

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Ndebele_South = 135

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Navajo = 136

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Chichewa_Chewa_Nyanja = 137

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Occitan = 138

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Ojibwa = 139

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Oromo = 140

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Oriya = 141

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Ossetian = 142

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Panjabi_Punjabi = 143

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Pali = 144

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Pushto = 145

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Puyallup = 146

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Quechua = 147

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Romansh = 148

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Rundi = 149

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Romanian = 150

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Kinyarwanda = 151

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Samoan = 152

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Sanskrit = 153

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Sardinian = 154

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Sindhi = 155

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Northern_Sami = 156

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Sango = 157

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Sinhalese = 158

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Slovak = 159

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    American_Sign_Language = 160

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Slovenian = 161

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Shona = 162

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Albanian = 164

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Serbian = 165

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Swati = 166

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Sotho_Southern = 167

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Sundanese = 168

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Swedish = 169

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Swahili = 170

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Tagalog = 171

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Tamil = 172

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Telugu = 173

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Tajik = 174

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Thai = 175

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Tigrinya = 176

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Turkmen = 177

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Tswana = 178

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Tonga = 179

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Turkish = 180

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Tsonga = 181

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Tatar = 182

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Twi = 183

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Tahitian = 184

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Uighur = 185

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Ukrainian = 186

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Urdu = 187

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Uzbek = 188

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Venda = 189

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Volapük = 190

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Walloon = 191

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Wolof = 192

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Xhosa = 193

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Yakima = 194

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Yiddish = 195

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Yoruba = 196

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Zhuang = 197

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Zulu = 198

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Afar = 199

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Abkhazian = 200

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Avestan = 201

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Maay_Maay = 202

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Karen = 203

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Kiswahili = 204

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Alhanian = 205

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Bangla = 206

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Haitian_Creole = 207

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Laotian = 208

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Panjabi = 209

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Rwanda = 210

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Sign_Language = 211

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Serbo_Croatian = 212

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Tagolog = 213

    <System.Runtime.Serialization.EnumMemberAttribute()> _
    Urvu = 214
End Enum

2 个答案:

答案 0 :(得分:2)

在WCF中,枚举通常由成员名称使用,而不是由数字枚举值使用。您可以通过EnumMember强制使用特定值(值:=&#34;&#34;)。或者您可以指定

<servicecontract(),XMLSerializerFormat> 

使用&#39; old&#39; xml序列化程序。

枚举序列化程序倾向于自动完成枚举。例如:

<DataContract>
Public Enum TheEnum As Integer
<EnumMember>
  value_1 = 1
<EnumMember>
  value_2 = 2
<EnumMember>
  value_3_1  
<EnumMember>
  value_3_2  
<EnumMember>
  value_3_3  
<EnumMember>
  value_4 = 4
<EnumMember>
  value_5  
<EnumMember>
  value_0 = 0
End Enum

会给你这个值:

  • value_1:1
  • value_2:2
  • value_3_1:3
  • value_3_2:4
  • value_3_3:5
  • value_4:4
  • value_5:5
  • value_0:0

所以我们可以说,这些价值节点,填补了空白。在显式节点之间&#39;值。并且,在这些情况下,max和&#39; 0&#39;价值,如果它们位于枚举的顶部,可能会被混淆。只试试这个:

把:

<System.Runtime.Serialization.EnumMemberAttribute()>  _
    LookUp = 9999

<System.Runtime.Serialization.EnumMemberAttribute()>  _
Unknown = 0

在枚举结束时,再试一次。

答案 1 :(得分:0)

刚刚使用.Net 4.5启动了一个使用Visual Studio 2013的新服务应用程序,我没有您的问题:

[ServiceContract]
public interface IService1
{

    [OperationContract]
    TestEnum GetData(int value);
}


[DataContract]
public enum TestEnum
{
    [EnumMember]
    Test1 =1,

    [EnumMember]
    Test3 = 3,
}

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://schemas.datacontract.org/2004/07/WcfService1" elementFormDefault="qualified" targetNamespace="http://schemas.datacontract.org/2004/07/WcfService1">
<xs:import namespace="http://schemas.microsoft.com/2003/10/Serialization/"/>
<xs:simpleType name="TestEnum">
<xs:restriction base="xs:string">
<xs:enumeration value="Test1">
<xs:annotation>
<xs:appinfo>
<EnumerationValue xmlns="http://schemas.microsoft.com/2003/10/Serialization/">1</EnumerationValue>
</xs:appinfo>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="Test3">
<xs:annotation>
<xs:appinfo>
<EnumerationValue xmlns="http://schemas.microsoft.com/2003/10/Serialization/">3</EnumerationValue>
</xs:appinfo>
</xs:annotation>
</xs:enumeration>
</xs:restriction>
</xs:simpleType>
<xs:element name="TestEnum" nillable="true" type="tns:TestEnum"/>
</xs:schema>