I\'ve heard some people saying that enums are evil and shouldn\'t be used in web services because of the mismatches that could occur between the server and the client if som
Real world story (values changed for anonymity) . Use to have an implicit enum
in the application
public enum { orange, banana, mango }
Some refactoring around order and new values, and we decide to make it explicit:
public enum { orange=1, banana=2, grape=3, mango=4 }
looks inoffensive ...
Next thing, a Website explodes. Scratch head, check service, add debug messages, all seems fine.
Down the rabbit hole, one day later, the reason is a base wcf service that was using the enum as a return type.
Apparenly , Wcf does not like enums with no default value.
Fix:
public enum { wcfBugBane=0, orange=1, banana=2, grape=3, mango=4 }
So ... it might bite you.
Enumerations are fully supported in WSDL and XSD through the xsd:enumeration
schema element. It provides support for both single values and flags-style enumerations, where multiple values in a flags enumeration are separated by spaces.
So you should have no problem using enumerations with any standards compliant platforms.
Of course, it all depends on where you are going to use this WCF service.
If it's a single application that will use it, then changing the contract won't have any effects.
If it's multiple internal applications, changing the contract might require some changes on the other applications.
And finally, if the WCF service is public, you might have to provide 2 versions of the service with differents version so that the people consuming them have the time to transfer their version of the client to the new service.
It all depends on your needs honestly.