ASMX Web服务枚举不保留它的价值 [英] ASMX web service Enum not retaining its value
问题描述
我已经创建了一个包含其值枚举如下Web服务
I have created a web service containing an enum with values as follows
public enum DesignChoice
{
DesignerChoice = 1,
CustomerChoice = 2,
AdditionalDesign=3,
}
当我添加引用我的客户的网站,枚举值在以下code变更为:
When I add a reference to my client website, enum values are changed as in the following code:
(INT)DesignChoice.AdditionalDesign
返回2,但我期待它是3。
(int)DesignChoice.AdditionalDesign
returns 2 but I am expecting it to be 3.
我已经尝试了序列化属性 [System.Xml.Serialization.XmlTypeAttribute()]
从哪儿冒出来,但没有运气。
I have tried the serialization attributes [System.Xml.Serialization.XmlTypeAttribute()]
out of nowhere but had no luck.
该服务的WSDL描述枚举如下:
WSDL of the service describes the enum as follows:
<s:simpleType name="DesignChoice">
<s:restriction base="s:string">
<s:enumeration value="DesignerChoice" />
<s:enumeration value="CustomerChoice" />
<s:enumeration value="AdditionalDesign" />
</s:restriction>
</s:simpleType>
当我在VS类名preSS F12它让我从元数据生成以下code:
When I press F12 on class name in VS it shows me the following code generated from meta data:
public enum DesignChoice
{
DesignerChoice = 0,
CustomerChoice = 1,
AdditionalDesign = 2,
}
我使用Visual Studio 2005和.NET 2.0。
I am using Visual Studio 2005 and .NET 2.0.
推荐答案
下面是发生了什么事情。
Here is the detail explanation what's going on
<一个href=\"http://www.kerrywong.com/2006/11/09/be-careful-when-using-enums-in-web-services/\">http://www.kerrywong.com/2006/11/09/be-careful-when-using-enums-in-web-services/
这篇关于ASMX Web服务枚举不保留它的价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!