473,395 Members | 2,446 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,395 software developers and data experts.

Using Enum type as Webservice Parameter

Hi,

I want to use the following:

Class Test ...

Public Enum TestEnum as integer
Enum1 = 128
Enum2 = 256
End Enum

<Webmethod...> _
Public Sub TestSub( parm as TestEnum)
....
End Sub
....
End Class

The enum we want to use is a enum from oracle .net client (db-datatypes)
which we can't change. TestEnum is only an example.

On client app we see the enum, but the corresponding values are wrong:
Enum1 = 0
Enum2 = 1

So if we call TestSub(TestEnum.Enum1) then value isn't 128 but 0 ?
If it would be a custom enum, we could change the values to correspond, but
we can't change the oracle enum values ????

Would be .NET Remoting a better way to program such things ?

Martin
Apr 6 '06 #1
2 7518
"Martin Engelhardt" <en********@noemail.noemail> wrote in message
news:A9**********************************@microsof t.com...
Hi,

I want to use the following:

Class Test ...

Public Enum TestEnum as integer
Enum1 = 128
Enum2 = 256
End Enum

<Webmethod...> _
Public Sub TestSub( parm as TestEnum)
...
End Sub
...
End Class

The enum we want to use is a enum from oracle .net client (db-datatypes)
which we can't change. TestEnum is only an example.

On client app we see the enum, but the corresponding values are wrong:
Enum1 = 0
Enum2 = 1

So if we call TestSub(TestEnum.Enum1) then value isn't 128 but 0 ?
If it would be a custom enum, we could change the values to correspond,
but
we can't change the oracle enum values ????

Would be .NET Remoting a better way to program such things ?

Martin


Hi Martin,

when enum is serialized to XML only its string representation is send to the
client. That's the whole idea of XML communication channel. If you want to
transfer also the numeric value, you need to implement a custom solution.
Remoting would work in this case, but your decision to you Remoting or not
should not be based on this particular problem. It depends much more on the
transport protocol, network and software environment and others.
See "Choosing Communication Options in .NET" [1] for more information how to
make your choice.

[1]
http://msdn.microsoft.com/library/de...tionsinnet.asp

Regards,

--
Martin Kulov
http://www.codeattest.com/blogs/martin

MVP, MCT, MCSD.NET Early Achiever

Apr 7 '06 #2
Hi Martin,

As Martin Kulov mentioned, generally enum types are represented by xsd
enumeration simple type like below:

<s:simpleType name="TestEnum">
- <s:restriction base="s:string">
<s:enumeration value="A" />
<s:enumeration value="B" />
</s:restriction>
</s:simpleType>

so it can not hold two value pairs(or the mapping info). For your
scenario,I think you can consider use the XmlEnumAttribute to
specify the enum's actual number value as the underlying xmlserialization
value. e.g:

=================
Public Enum TestEnum As Integer

<XmlEnum("128")> _
Enum1 = 128

<XmlEnum("256")> _
Enum2 = 256

End Enum
====================

thus, the "Enum1" will be transfered as "128", "Enum2" will be transfered
as "256" in SOAP message, and when arrive the other side, it will be
deserizlied to the .net enum value.

Hope this helps.

Regards,

Steven Cheng
Microsoft Online Community Support
==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Apr 7 '06 #3

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

Similar topics

1
by: Alexander Stippler | last post by:
Hello, some time ago I learnt much about restricting template parameters by checking some properties upon these and exploiting SFINAE. But the existence of unnamed enum types makes me doubt if...
20
by: Glenn Venzke | last post by:
I'm writing a class with a method that will accept 1 of 3 items listed in an enum. Is it possible to pass the item name without the enum name in your calling statement? EXAMPLE: public enum...
2
by: msnews.microsoft.com | last post by:
How do I get Intellisense to open a dropdown list box for a method's parameters when the parameter is an ENUM? public class MyClass { public enum IDkind { PersonID, EntityID, PlaceID
31
by: Michael C | last post by:
If a class inherits from another class, say Form inherits from control, then I can assign the Form to a variable of type Control without needing an explicit conversion, eg Form1 f = new Form1();...
7
by: chukkykzn | last post by:
Hi I'd like to pass an entire enumeration to a method. Not sure how it's done. Eg: enum MyEnum { one = 1, two = 2 } class Test
0
by: Nalla | last post by:
Hi, I have a requirement to call webservices from my old C++ application.So first I tried with Vc++.net as follows.....There are 2 approach Dotnet frame work and soaptoolkit 3.0 I am not able to...
21
by: dllhell | last post by:
hi all, I have a problem with creating proc with a enum as a param. I wish to pass an enumeration in proc in which one I intend to do some operations with enumeration, but I don't know which one...
6
by: bsma1 | last post by:
I building a web service that has an enum I want the consuming application to be able to use. I have the enum declared in the web service as: public enum myEnum { ONE = 1, TWO = 2, };
8
by: benn | last post by:
Here's the setup... Defines.h file contains: enum DAY { monday, tueday }; DayFunctions.h contains prototype: void printIsMonday ( enum DAY currentDay); DayFunctions.c contains:
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.