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
}
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();
}
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?
Be aware that there are issues with enumerations and web services.
See this question.
In the languages derived from C (C#, C++, Java), an
enum
is effectively a set of named integral values.There is no corresponding concept in XML Schema, therefore there is no such concept in web services.
Before you or anyone else mentions the
<xs:enumeration/>
facet, that's not what it's for.<xs:enumeration/>
provides a list (an enumeration) of the possible lexical values for a type. There is no way to associate numbers with those lexical values. The followingenum
:becomes the following XML Schema:
Note the absence of 1, 2, or 4.
All this says is that an element or attribute of this type will be a string, and may have one of the values "E1a", "E1b", or "E1c".
If a client proxy is built from a WSDL with such schema, and if the proxy code generator is smart enough, it may decide that this was originally a programming language
enum
. In this case, it would create the type asSince it has no access to the integers.
There are some bugs listed at Adobe re: Flex 3 and enum's in WSDL .. Are you sure you have the latest update ?