Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Services > Enum Problems

Reply
Thread Tools

Enum Problems

 
 
Oldman
Guest
Posts: n/a
 
      07-03-2006
I have an enum being passed into one of my webservice methods.
The actual enum is defined as follows:

[pre]
public enum StatusType
{
SPECIAL_1 = -2,
SPECIAL_2 = -1,
ENUM1 = 1,
ENUM2,
ENUM3,
ENUM4
}
[/pre]

The issue is that this is created in the proxy class like this:

[pre]
public enum StatusType
{
SPECIAL_1,
SPECIAL_2,
ENUM1,
ENUM2,
ENUM3,
ENUM4
}
[/pre]

So when the client passes up ENUM4 the web service thinks it has ENUM2.
Is there are way to fix this?

Thanks,

Chris
 
Reply With Quote
 
 
 
 
Martin.Kunc@gmail.com
Guest
Posts: n/a
 
      07-04-2006
Hallo Oldman,
I was confused, so I have tried this one out. In fact, when you are
passing enum types - during wsdl and everywhere on its way it is passed
as string (complex string type with restriction). So it does not matter
what enumeration id you assign them, you are allways passing enum's
item name.
I suppose, here in your case could be any other mistake before you pass
this enum type to webservice.

**I have used this client for my tests:
static void Main(string[] args) {
localhost.Service ss = new EnumType_WSTesting.localhost.Service();
localhost.StatusType st;
foreach (string s in Enum.GetNames(typeof(localhost.StatusType))) {
Console.WriteLine(
ss.HelloWorld(
(localhost.StatusType)Enum.Parse(typeof(localhost. StatusType),
s),
out st)
);
Console.WriteLine(string.Format(" out st: {0}",st));
}
Console.ReadKey();
}
**And this code as webservice:
public enum StatusType
{
SPECIAL_1 = -2,
SPECIAL_2 = -1,
ENUM1 = 1,
ENUM2,
ENUM3,
ENUM4
}
[WebMethod]
public string HelloWorld(StatusType stin, out StatusType stout) {
stout = stin;
return stin.ToString();
}
---
enjoy, Martin

Oldman wrote:
> I have an enum being passed into one of my webservice methods.
> The actual enum is defined as follows:
>
> [pre]
> public enum StatusType
> {
> SPECIAL_1 = -2,
> SPECIAL_2 = -1,
> ENUM1 = 1,
> ENUM2,
> ENUM3,
> ENUM4
> }
> [/pre]
>
> The issue is that this is created in the proxy class like this:
>
> [pre]
> public enum StatusType
> {
> SPECIAL_1,
> SPECIAL_2,
> ENUM1,
> ENUM2,
> ENUM3,
> ENUM4
> }
> [/pre]
>
> So when the client passes up ENUM4 the web service thinks it has ENUM2.
> Is there are way to fix this?
>
> Thanks,
>
> Chris


 
Reply With Quote
 
 
 
 
Oldman
Guest
Posts: n/a
 
      07-04-2006
I have read the same thing but try it out. If you pass up a status type from
the client to the server you get the behavior I described. I have not had
problems passing back statuses from the server to client.

However, I seemed to have fixed my problem by adding XmlEnum attributes to
the Enum. I will dig into this some more but let me know if you can
reproduce the problem I described.

Thanks,

Chris

"(E-Mail Removed)" wrote:

> Hallo Oldman,
> I was confused, so I have tried this one out. In fact, when you are
> passing enum types - during wsdl and everywhere on its way it is passed
> as string (complex string type with restriction). So it does not matter
> what enumeration id you assign them, you are allways passing enum's
> item name.
> I suppose, here in your case could be any other mistake before you pass
> this enum type to webservice.
>
> **I have used this client for my tests:
> static void Main(string[] args) {
> localhost.Service ss = new EnumType_WSTesting.localhost.Service();
> localhost.StatusType st;
> foreach (string s in Enum.GetNames(typeof(localhost.StatusType))) {
> Console.WriteLine(
> ss.HelloWorld(
> (localhost.StatusType)Enum.Parse(typeof(localhost. StatusType),
> s),
> out st)
> );
> Console.WriteLine(string.Format(" out st: {0}",st));
> }
> Console.ReadKey();
> }
> **And this code as webservice:
> public enum StatusType
> {
> SPECIAL_1 = -2,
> SPECIAL_2 = -1,
> ENUM1 = 1,
> ENUM2,
> ¨ ENUM3,
> ENUM4
> }
> [WebMethod]
> public string HelloWorld(StatusType stin, out StatusType stout) {
> stout = stin;
> return stin.ToString();
> }
> ---
> enjoy, Martin
>
> Oldman wrote:
> > I have an enum being passed into one of my webservice methods.
> > The actual enum is defined as follows:
> >
> > [pre]
> > public enum StatusType
> > {
> > SPECIAL_1 = -2,
> > SPECIAL_2 = -1,
> > ENUM1 = 1,
> > ENUM2,
> > ENUM3,
> > ENUM4
> > }
> > [/pre]
> >
> > The issue is that this is created in the proxy class like this:
> >
> > [pre]
> > public enum StatusType
> > {
> > SPECIAL_1,
> > SPECIAL_2,
> > ENUM1,
> > ENUM2,
> > ENUM3,
> > ENUM4
> > }
> > [/pre]
> >
> > So when the client passes up ENUM4 the web service thinks it has ENUM2.
> > Is there are way to fix this?
> >
> > Thanks,
> >
> > Chris

>
>

 
Reply With Quote
 
Oldman
Guest
Posts: n/a
 
      07-04-2006
Whoops, sorry I looked at your example again and noticed you are passing up a
status from the client. The first time I looked at it I just saw the out
parameter.
Hmm. Ok, I'll dig deeper.

Thanks,

Chris

"(E-Mail Removed)" wrote:

> Hallo Oldman,
> I was confused, so I have tried this one out. In fact, when you are
> passing enum types - during wsdl and everywhere on its way it is passed
> as string (complex string type with restriction). So it does not matter
> what enumeration id you assign them, you are allways passing enum's
> item name.
> I suppose, here in your case could be any other mistake before you pass
> this enum type to webservice.
>
> **I have used this client for my tests:
> static void Main(string[] args) {
> localhost.Service ss = new EnumType_WSTesting.localhost.Service();
> localhost.StatusType st;
> foreach (string s in Enum.GetNames(typeof(localhost.StatusType))) {
> Console.WriteLine(
> ss.HelloWorld(
> (localhost.StatusType)Enum.Parse(typeof(localhost. StatusType),
> s),
> out st)
> );
> Console.WriteLine(string.Format(" out st: {0}",st));
> }
> Console.ReadKey();
> }
> **And this code as webservice:
> public enum StatusType
> {
> SPECIAL_1 = -2,
> SPECIAL_2 = -1,
> ENUM1 = 1,
> ENUM2,
> ¨ ENUM3,
> ENUM4
> }
> [WebMethod]
> public string HelloWorld(StatusType stin, out StatusType stout) {
> stout = stin;
> return stin.ToString();
> }
> ---
> enjoy, Martin
>
> Oldman wrote:
> > I have an enum being passed into one of my webservice methods.
> > The actual enum is defined as follows:
> >
> > [pre]
> > public enum StatusType
> > {
> > SPECIAL_1 = -2,
> > SPECIAL_2 = -1,
> > ENUM1 = 1,
> > ENUM2,
> > ENUM3,
> > ENUM4
> > }
> > [/pre]
> >
> > The issue is that this is created in the proxy class like this:
> >
> > [pre]
> > public enum StatusType
> > {
> > SPECIAL_1,
> > SPECIAL_2,
> > ENUM1,
> > ENUM2,
> > ENUM3,
> > ENUM4
> > }
> > [/pre]
> >
> > So when the client passes up ENUM4 the web service thinks it has ENUM2.
> > Is there are way to fix this?
> >
> > Thanks,
> >
> > Chris

>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems Compiling enum.h from ENUM++ Randy C++ 1 01-07-2006 10:52 PM
enum: display elements of an enum specified at runtime Jerminia Java 3 10-07-2005 10:08 PM
enum within an enum - Java 6 06-13-2005 12:51 AM
Including an enum within another enum, possible? mrhicks C Programming 2 06-10-2004 03:00 AM
How to enum an enum? Ernst Murnleitner C++ 5 11-13-2003 11:06 AM



Advertisments