473,804 Members | 2,460 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(TestEnu m.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 7549
"Martin Engelhardt" <en********@noe mail.noemail> wrote in message
news:A9******** *************** ***********@mic rosoft.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(TestEnu m.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:restrictio n base="s:string" >
<s:enumeratio n value="A" />
<s:enumeratio n 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 XmlEnumAttribut e to
specify the enum's actual number value as the underlying xmlserializatio n
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
6562
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 this approach can be helpful in a general project. An example: I have an operator/(), which I would like to overload for vector/T, where T is long, double, .... I want to be able to use any type, which is convertible to vector, so I use SFINAE...
20
4852
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 EnumName FirstValue = 1 SecondValue = 2 ThirdValue = 3
2
5699
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
3622
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(); Control c = f; An enum value inherits from int but it doesn't get implicitly converted: HorizontalAlignment h = HorizontalAlignment.Center;
7
1595
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
6209
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 interact with webservice thru c++.I think ther is a bug in MS implementation for c++ to interact with webservice because I am able to connect to the same webservice thru C# as well as vb.net. I tried the following approaches
21
2181
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 enumeration I'll pass. so... I have tried with: string SomeResult (enum** _enum) { }
6
10060
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
8564
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
9704
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9571
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10561
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10302
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7608
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6845
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5639
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4277
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.