views:

152

answers:

0

I have some web services that use Message contracts. It's probably worth mentioning that for these services, I cannot shift to Data contracts...

One of my types specifies a property whose type happens to be an enum:

[SerializableAttribute()]
[MessageContract(IsWrapped = false)]
[KnownType(typeof(RiskTypeCode))]
public partial class RiskType : Lookup
{

    private RiskTypeCode codeField;

    /// <remarks/>
    [XmlElement(ElementName="code")]
    [MessageBodyMember]
    public RiskTypeCode Code
    {
        get
        {
            return this.codeField;
        }
        set
        {
            this.codeField = value;
        }
    }

e.t.c.

My enum is defined as:

[Serializable()]
[DataContract]
public enum RiskTypeCode
{

    /// <remarks/>
    [XmlEnumAttribute(Name = "THING1")]
    [EnumMember]
    THING1,

    /// <remarks/>
    [XmlEnumAttribute(Name="THING2")]
    [EnumMember]
    THING2,

    /// <remarks/>
    [XmlEnumAttribute(Name="THING3")]
    [EnumMember]
    THING3,
}

But when I send this across the wire, the RiskTypeCode property is not serialised - i.e. it's ommitted from the output.

What do I need to decorate my enum/property with to get it across the wire?

Thanks, -Rob-