C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Enum in webservices ?


Posted Date: 18 Aug 2008      Total Responses: 2

Posted By: avtar       Member Level: Gold     Points: 1


Suppose there is class with enum

public enum Color
{
Red = 20,
Black = 13
}

And suppose there is a method

public void SetColor (int id, Color c)
{

}

When web service proxy class is generated the value of the enums will be
lost:

public enum Color
{
Red,
Black
}

so that essentially Red = 1 and Black = 2

That creates some problems. For example if Red = 20 and Black = 13 are
database keys, it is impossible to update the database via web service,
since the passing values are different.

I can see two solutions for this:

1. Manually update enum in proxy class to
public enum Color
{
Red = 20,
Black = 13
}

2. Change

public void SetColor (int id, Color c)

to

public void SetColor (int id, int c)

I don't really like either one.

Any thoughts or ideas?.....

and is same resolved in WCF ?




Responses

Author: vipul    18 Aug 2008Member Level: DiamondRating:     Points: 6
hi,
you can't access the enum in your page, Here i put the example and how to use enum the aspx.cs page

in Webservice
==============
public enum MailTypes
{
Yahoomail = 1,
Hotmail = 2,
Gmail = 3,
AOLmail = 4,
Rediffmail = 5
}
[WebMethod]
public string Getalladdress(MailTypes Mailtypes,string txtUserName, string txtPassword)
{
}

In other web site
=================
Getaddress objAddress = new Getaddress();
// this is class of the web service where i declare web method
strdata = objAddress.Getalladdress(MailTypes.Hotmail, txtUserName.Text.ToString(), txtPassword.Text.ToString());


vipul,
http://dongavipul.blogspot.com



Author: avtar    18 Aug 2008Member Level: GoldRating:     Points: 3
In this example what will be the value of MailTypes.Hotmail ? if in enum its 20 ? it will be 2 rite...? is there a way to get exact enum value ? and is this same problem in wCF as well ?


Post Reply
You must Sign In to post a response.
Next : Architecture
Previous : WEBSERVICE
Return to Discussion Forum
Post New Message
Category: Webservices

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design

conference calls

Contact Us    Privacy Policy    Terms Of Use