473,383 Members | 1,818 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Web service returning enumerated type

Rob
Hi,

I have defined an enumeration thus:

Public Enum CollectionDayOfWeek
NoCollectionDay = -1
Sunday = DayOfWeek.Sunday
Monday = DayOfWeek.Monday
Tuesday = DayOfWeek.Tuesday
Wednesday = DayOfWeek.Wednesday
Thursday = DayOfWeek.Thursday
Friday = DayOfWeek.Friday
Saturday = DayOfWeek.Saturday
End Enum

I have a web service which returns a value of this type.

Now when I run wsdl to create my proxy, the enumeration loses its
initializers so that NoCollectionDay = 0, Sunday = 1, etc.

Can I do anything to correct this behaviour? Or am I better off not setting
initializers on my enumerations when writing web services?

Thanks,

Rob
Nov 21 '05 #1
5 2657
Hi Rob,

Since web services are using xml/soap it is better the data that you pass through to be human readable. The purpose is not to be just read by humans, but to maintain compatibility in the future. So if I were you I would implement it returning the strings themselves. The enum type even has a GetName method that does the exact thing.

Best regards,
Martin Kulov
www.codeattest.com

Nov 21 '05 #2
Rob
Hi Martin,
Thanks for the reply. Yes looking at the WSDL for my web service I can see
that my enumeration is described in text only. As you say I guess that I am
limited to returning either the string itself or not attempting any form of
initialization.

The reason I noticed this is that in my proxy I attempted to convert the day
to a DayOfWeek type and noticed that Wednesday became Tuesday. If I want to
do this sort of conversion then I am best doing it through the name of the
value.

Regards,

Rob
Nov 21 '05 #3
Hi Rob,
I do not know how Wednesday became Thursday. May be it is some time zone issue. How did you convert DayOfWeek type?
IMHO DayOfWeek.Friday.ToString() should always return Friday.

Regards,
Martin

Nov 21 '05 #4
Rob
Hi Martin,
Sorry - I wasn't very clear in my last post.

In my web service my enumeration is defined as follows

Public Enum CollectionDayOfWeek
NoCollectionDay = -1

End Enum
Nov 21 '05 #5
Rob
Last post was mangled...

My enumeration in the web service is defined as

Public Enum CollectionDayOfWeek
NoCollectionDay = -1
Sunday = DayOfWeek.Sunday
Monday = DayOfWeek.Monday
etc
End Enum
My proxy does not have the initializers so the enumeration here is
(Parentheses are mine)

Public Enum CollectionDayOfWeek
NoCollectionDay (=0)
Sunday (=1)
Monday (=2)
etc
End Enum

So if in my client I have a variable of type CollectionDayOfWeek and cast it
to DayOfWeek as follows
CType(var, DayOfWeek) then Sunday becomes Monday, Monday becomes Tuesday etc.

I agree though that my approach is flawed - I just wanted to explain how I
noticed that I had a problem in the first place.

Regards,

Rob
Nov 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Rob Richardson | last post by:
Greetings! I have a module that contains the following: Module Globals Public thePortfolio As clsPortfolio Public Enum OrderResult ORDER_FAILED ORDER_GOOD ORDER_PENDING ORDER_CANCELED
22
by: Ben Finney | last post by:
Howdy all, I've recently packaged 'enum' in PyPI. In its description, I make the claim that it creates "immutable" enumeration objects, and that the enumeration values are "constant" values. ...
1
by: davidmcb | last post by:
I have defined an enumerated type that I use in various places in my schema. I am in the process of creating a new complex type that contains an attribute that I want to restrict to NOT being a...
4
by: Shawnk | last post by:
This post is intended to verify that true value semantics DO NOT EXIST for the Enum class (relative to boolean operations). If this is true then (thus and therefore) you can not design state...
5
by: Jim Murphy | last post by:
In creating a C# web service, I am having trouble returning a DataTable object as the result of a web method. I have no problem returning native types like string or int, but cannot return a .NET...
0
by: jjoy | last post by:
After upgrading to 2.0/VS2005, one of the web services we consume no longer worked. It defines an enumerated type that is then used in several classes within the proxy code. The proxy code now...
7
by: John Goche | last post by:
Hello, The following program compiler and runs fine under gcc and produces the output 3. However, I am not sure whether such behavior is legal. In particular, as a related question, how would I...
15
by: Joseph Geretz | last post by:
I'm a bit puzzled by the current recommendation not to send Datasets or Datatables between application tiers. http://support.microsoft.com/kb/306134 ...
5
by: Frank Hauptlorenz | last post by:
Hello, I recognized some days ago, that returning a DataTable blocks my WCF-Service. Is this a known bug? If I add this table to a new DataSet() and return this, it works. Thank you, Frank
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.