How to Expose Enums using WCF service

Hello,

I have a requirement that i need to expose my enums usign WCF service, Can any one provide me with the link.How to expose Enums using WCF service and how to consume them in at the client end..........



I have exposed enum in the below mentioned format, but when i am trying to acess the same at the client end i am not getting enum name in the intellisense..........

Code: Way i created enum in WCF project

[DataContract( Name = "QuestionType1")]
    public enum QuestionType
    {
        [EnumMember]
        MultipleChoice_OnlyOneAnswer = 1,
        [EnumMember]
        MultipleChoice_MultipleAnswer = 2,
        [EnumMember]
        CommentOrEssayBOx = 3,
        [EnumMember]
        MatrixOfChoice_OnlyOneAnswerPerRow = 4,
        [EnumMember]
        MatrixOfChoice_MultipleAnswerPerRow = 5,
        [EnumMember]
        DropDownMenu = 6,
        [EnumMember]
        SingleTextBox = 7,
        [EnumMember]
        DescriptiveText = 9,
        [EnumMember]
        DemographicInformation_US = 10,
        [EnumMember]
        DemographicInformation_International = 11,
        [EnumMember]
        DateorTime = 12,
        [EnumMember]
        Email = 13,
        [EnumMember]
        HelpText = 14,
        [EnumMember]
        MultipleTextBox = 15,
        [EnumMember]
        PhoneNumber = 16,
        [EnumMember]
        NumberDropDownMenu = 17
    }


I am not able to find QuestionType1 when i am trying to consume this service...............




LVL 1
Praveen_BobbiliAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kiran SonawaneProject LeadCommented:
Not sure but QuestionType enum should be used in one of data contract for instance

[DataContract]
public enum UserDetails
{
   [DataMember]
   public string name;

    [DataMember]
   public QuestionType enum_test;

}
0
gopaltaydeCommented:
Generally DataContracts are kept in a seperate projects and it's reference is added in wcf service project and client project. This way we can access the data contracts.
The another way is suggested by sonawanekiran. The example is available at http://beyondrelational.com/blogs/dhananjaykumar/archive/2011/03/18/enumeration-in-datacontract-of-wcf.aspx
0
Praveen_BobbiliAuthor Commented:
Hello,

Reason for the issue i have not decorated my Contract with ServiceKnownType attribute.

If i decorate my interface in the below format i am able to access Enum at my client end.........

 [ServiceKnownType(typeof(QuestionType))]
 public interface ISurveyOperations
{

}  
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Praveen_BobbiliAuthor Commented:
The comments given by the team not helped me in getting the solutions are even it not helped me work towards the solution.   When ever i have discussed this issue with my other team members i have got the solution...............
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
WCF

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.