Using Enum as a parameter in web service

D

dave

I am having trouble using an enum as a parametter in a webmethod. I have
followed the 'resolution' per
http://support.microsoft.com/Default.aspx?id=326792 however in my client app
i am not sure how to access and use the enum.

Any help would be greatly appreciated.

ie. this is my web service

Public Enum uType
All
Information
End Enum

Public Class EnumWrapper
Public UpdateType As uType
End Class

<WebMethod(), XmlInclude(GetType(EnumWrapper))> _
Public Function fUpdate(ByVal idAs Integer, ByVal Type As EnumWrapper)
As Boolean

.....

how would i call this method fUpdate in client app

Dim bol As Boolean = wsContact.fUpdate(id, ????)
 
M

Mujtaba Syed

Dave:

The enum will be available in your proxy too.

So,
Dim bol As Boolean = wsContact.fUpdate(id, ????)

???? = <Proxy-namespace>.uType.<Enum-value>

Thanks,
Mujtaba.
 
D

dave

Something still is not quite right as when I do the following

Dim bol As Boolean = wsContact.fUpdate(id,
<Proxy-namespace>.uType.<Enum-value>)

I get an error:
uType is not a member of <appname>.<proxy-namespace>.<class>

I have update all web service references and still get this 'not a member'
error. Any ideas?
thx
 
M

Mujtaba Syed

Dave:

Define the uType enum as a _nested_ enum to your web service class.
Something like this:

<%@ WebService class="MyService" Language="C#" %>

public class MyService : System.Web.Services.WebService
{
public enum Num
{
Zero,
One,
Two,
Three
}

[System.Web.Services.WebMethodAttribute]
public string Do (Num x)
{
return x.ToString ();
}
}

Mujtaba.
 

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

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top