Ok, Im having major problems trying to expose this enumerated type over my webservice. It does not function in the same way as my custom classes, in terms of exposing them.
ServerSide:
[DataContractAttribute]
public enum EventReportType {EventAutoContract, DailyAutoContract, EventFunctionSheet }
Clientside:
// For a custom class I would do:
ServerRef.MyClass maclass = new ServerRef.MyClass();
// but the following does not work.
ServerRef.EventReportType myenum = new ServerRef.EventReportType();
enum test = new ServerRef.EventReportType();
I dont think its even in the WSDL, so how do I get it to expose properly?
And how would I consume and use it?
Please look at my other question too for a bounty : REST with nullable types?
Because the type is an
enum, you don’t create instances of it, you access static representations of values.For instance,
But in general, you won’t assign the value to a variable unless you need to, you would just use it explicitly; so, say calling a service method which accepts an enum value from this type:
Note that you don’t need to explicitly spell out the
DataContractAttributeeither, this can be shorthanded toDataContract, also, you probably require eachenummember to be augmented with theEnumMemberattribute, too. So…You can find a reference for using enumeration types in data contracts here. Ultimately, if your
enumis properly defined and used somewhere in the service which is exposed to the client side, then theenumwill be generated.