views:

275

answers:

1

I added a custom attribute to an enum that I was using as part of a web service. When I add the web service as a service reference to a win forms application the custom attributes do not appear in the service reference proxy objects although the enum type itself does appear. I've looked all over and haven't found anything close to a solution.

Am I trying to do something that is not possible?

Server side code: public enum ServiceEnum { [ServiceEnumTest("Boat")]item1, [ServiceEnumTest("Plane")]item2, [ServiceEnumTest("Bicycle")]item3, [ServiceEnumTest("Car")]item4, item5 }

Client side proxy generated code:

[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "3.0.0.0")]
[System.Runtime.Serialization.DataContractAttribute(Name="ServiceEnum", Namespace="http://tempuri.org/")]
public enum ServiceEnum : int {

    [System.Runtime.Serialization.EnumMemberAttribute()]
    item1 = 0,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    item2 = 1,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    item3 = 2,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    item4 = 3,

    [System.Runtime.Serialization.EnumMemberAttribute()]
    item5 = 4,
}
+1  A: 

Attributes are a language feature, and there's no standard way to represent them in a SOAP message. So what you're trying is impossible. You could, instead, add the type as an attribute, or write a custom serialiser which moves the .NET attribute value to an XML attribute, but that's not going to be portable - it won't hydrate back on the other side without a lot of work.

blowdart