0

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?

Drew Noakes
  • 300,895
  • 165
  • 679
  • 742
SkunkSpinner
  • 11,429
  • 7
  • 40
  • 53
  • did you ever get this working? I'm in the same situation but I dont really care about the numerical values, just want it to be populated and not always null – Darko Jan 04 '10 at 22:43

3 Answers3

1

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

See this question.

  • Should be using [Serializable,Flags] in web service.
  • Flags should be multiples of two
  • The enumeration definition should start from 1 rather than 0.
Community
  • 1
  • 1
rbrayb
  • 46,440
  • 34
  • 114
  • 174
0

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 following enum:

public enum Enumeration1
{
    E1a = 1,
    E1b = 2,
    E1c = 4
}

becomes the following XML Schema:

<s:simpleType name="Enumeration1">
    <s:restriction base="s:string">
        <s:enumeration value="E1a"/>
        <s:enumeration value="E1b"/>
        <s:enumeration value="E1c"/>
    </s:restriction>
</s:simpleType>

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 as

public enum Enumeration1
{
    E1a,
    E1b,
    E1c
}

Since it has no access to the integers.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
0

There are some bugs listed at Adobe re: Flex 3 and enum's in WSDL .. Are you sure you have the latest update ?

Scott Evernden
  • 39,136
  • 15
  • 78
  • 84