Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / June 2004

Tip: Looking for answers? Try searching our database.

Making enum visible to client ??

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
cmrchs@yahoo.com - 15 Jun 2004 11:25 GMT
Hi,

how can I make an enum type visible to a WebService-client ?
Here's what I mean :

declaring a class in the WebService :
 public class MyClass
 {...}

makes it available for the client, but ....

declaring an enum in the WebService :
 public enum MyEnum
 {...}

does not make it available for the client.

How can make MyEnum available anyway ?

Thanks

Chris
Dino Chiesa [Microsoft] - 16 Jun 2004 01:19 GMT
If you return an enum type from a webservice, the enum type appears in the
client-side generated proxy.

Eg, if this is my asmx:
<%@ WebService Language="C#" Class="TrialService" %>

public enum MyEnum {
 Blue,
 Green,
 Yellow,
 Red
}

[System.Web.Services.WebService(Namespace="http://dinoch.dyndns.org/webservi
ces/")]
public class TrialService {
 static System.Random rnd= new System.Random();
 [System.Web.Services.WebMethod(Description="Method that returns an enum")]
 public MyEnum Method2(int input) {
   System.Array a= System.Enum.GetValues(typeof(MyEnum));
   MyEnum result= (MyEnum) System.Enum.Parse(typeof(MyEnum),
rnd.Next(a.Length).ToString());
   return result;
 }
}

Then if I run wsdl.exe on that asmx, I get
/// <remarks/>
[System.Xml.Serialization.XmlTypeAttribute(Namespace="http://dinoch.dyndns.o
rg/webservices/")]
public enum MyEnum {

   /// <remarks/>
   Blue,

   /// <remarks/>
   Green,

   /// <remarks/>
   Yellow,

   /// <remarks/>
   Red,
}

in the client-side proxy.

-Dino

> Hi,
>
[quoted text clipped - 22 lines]
> Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
> Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.