Making enum visible to client ??

C

cmrchs

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



**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
 
D

Dino Chiesa [Microsoft]

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


Chris C said:
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



**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP &
ASP.NET resources...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top