Flex、.NET Web 服务和数字枚举 [英] Flex, .NET Web Service and Numeric Enums

查看:29
本文介绍了Flex、.NET Web 服务和数字枚举的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用 Flex 3 来使用 .NET Web 服务.Web 服务使用枚举,我们使用 Flex Builder 自动生成 Web 服务对象.这是 .NET Web 服务枚举定义:

We're using Flex 3 to consume a .NET Web Service. The web service uses an enum and we use Flex Builder to automatically generate the web service objects. Here is the .NET web service enum definition:

 /// <summary>
   /// User type
   /// </summary>
   public enum UserTypeEnum
   {
       Admin = 1,
       User = 3,
       Manager = 4
   }

当 Flex 生成 Web 服务对象时,它将它们视为字符串而不是整数值.

When Flex generates the web service objects, it treats them as strings instead of integer values.

[Inspectable(category="Generated values", enumeration="Admin, User, Manager", type="String")]
public var _UserTypeEnum:String;public function toString():String
{
return _UserTypeEnum.toString();
}

当我们从 Web 服务获取数据时,任何使用此枚举的属性都是 Null,而不是 'admin' 或 '1'.有什么办法可以让这个工作吗?

When we get data from the web service, any property that uses this enumeration is Null instead of 'admin' or '1'. Is there any way to make this work?

推荐答案

请注意枚举和 Web 服务存在问题.

Be aware that there are issues with enumerations and web services.

请参阅此问题.

  • 应该在网络服务中使用 [Serializable,Flags].
  • 标志应该是 2 的倍数
  • 枚举定义应该从 1 而不是 0 开始.

这篇关于Flex、.NET Web 服务和数字枚举的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆