"John Saunders" <john.saunders at trizetto.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
"Mariano Omar Rodriguez" <mr******@yahoo.comwrote in message
news:eu**************@TK2MSFTNGP02.phx.gbl...
>Apply the Attribute XmlEnumAttribute for each option of the enumearion.
I don't believe that this will permit the client to treat the type as an
"enum". The reason is that there is no such thing as an enum in XML
Schema, and XML Schema is what is used to communicate type information
from server to client via the WSDL.
Ok, I take back part of this.
If you have an enum type like this:
public enum MyEnum
{
One = 1,
Two = 2
}
Then this will be translated into the following XML Schema type:
<s:simpleType name="MyEnum">
<s:restriction base="s:string">
<s:enumeration value="One" />
<s:enumeration value="Two" />
</s:restriction>
</s:simpleType>
This will cause the following client proxy to be created:
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("Sy stem.Xml",
"2.0.50727.42")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespac e="http://tempuri.org/")]
public enum MyEnum {
/// <remarks/>
One,
/// <remarks/>
Two,
}
Note that the integer value of "One" on the client is zero.
The reason that I didn't think this would work is that the web services I've
recently created couldn't simply use s:restriction base="string". They had
to use s:restriction base="s:int".
Note that you can get some interesting effects when your <s:enumeration>
values are not valid .NET identifiers. For instance, an enum member with
value "a b c" gets the name "abc" on the client:
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("Sy stem.Xml",
"2.0.50727.42")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespac e="urn:customerSpecific.types.umcase.um.cca.webser vices.trizetto.com")]
public enum aaTesting {
/// <remarks/>
[System.Xml.Serialization.XmlEnumAttribute("a b c")]
abc,
/// <remarks/>
[System.Xml.Serialization.XmlEnumAttribute("d e f")]
def,
}
John