WSDL, Enums and C#: It's still murky

后端 未结 1 1829
醉话见心
醉话见心 2021-01-18 05:18

I tried to look this up online, but all the WSDL examples seem to not really explain if I should mark things as basetype string in the WSDL or int...

Basically, I\'m

相关标签:
1条回答
  • 2021-01-18 05:33

    Enumerations will end up looking like their string representations. So the correct wsdl will present the enums as:

    <xs:simpleType name="MyEnum">
        <xs:restriction base="xsd:string">
          <xs:enumeration value="Item1" />
          <xs:enumeration value="Item2" />
          <xs:enumeration value="Item3" />
          <xs:enumeration value="SpecialItem" />
        </xs:restriction>
      </xs:simpleType>
    

    The above will automatically serialize/deserialize to the MyEnum enumeration type for you. If you present the enums as xsd:int then you will end up having to convert them manually back and forth.

    You can refer to the enumeration definition within your schema like so:

    <xsd:complexType name="Class1">
        <xsd:sequence>
          <xsd:element minOccurs="1" maxOccurs="1" name="MyEnumProperty" type="MyEnum" />
        </xsd:sequence>
      </xsd:complexType>
    
    0 讨论(0)
提交回复
热议问题