473,888 Members | 1,419 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Public Enums in Web service

Is there any way of getting a public enumeration to be generated into a web
service proxy?
Nov 21 '05 #1
5 12537
DMitchell wrote:
Is there any way of getting a public enumeration to be generated into
a web service proxy?


This works for me:

<codeSnippet language="C#">
[Flags]
public enum TestEnum
{
None = 0,
Value1 = 1,
Value2 = 2
}

[WebMethod]
public TestEnum ReturnEnum()
{
return TestEnum.None;
}
</codeSnippet>

It generates the following Schmea within the WSDL:

<s:simpleType name="TestEnum" >
<s:list>
<s:simpleType >
<s:restrictio n base="s:string" >
<s:enumeratio n value="None" />
<s:enumeratio n value="Value1" />
<s:enumeratio n value="Value2" />
</s:restriction>
</s:simpleType>
</s:list>
</s:simpleType>

Which the proxy generator seems to parse just fine. I end up with the same
enum on the client. Also beware that the values will not be the same, but
they don't need to be since the enum name is all that matters in the realm
of XML.

HTH,
Dre

Nov 21 '05 #2
Thanks Drew. Have tried that and just does not generate anything into the
proxy. Will try on another machine.

"Drew Marsh" wrote:
DMitchell wrote:
Is there any way of getting a public enumeration to be generated into
a web service proxy?


This works for me:

<codeSnippet language="C#">
[Flags]
public enum TestEnum
{
None = 0,
Value1 = 1,
Value2 = 2
}

[WebMethod]
public TestEnum ReturnEnum()
{
return TestEnum.None;
}
</codeSnippet>

It generates the following Schmea within the WSDL:

<s:simpleType name="TestEnum" >
<s:list>
<s:simpleType >
<s:restrictio n base="s:string" >
<s:enumeratio n value="None" />
<s:enumeratio n value="Value1" />
<s:enumeratio n value="Value2" />
</s:restriction>
</s:simpleType>
</s:list>
</s:simpleType>

Which the proxy generator seems to parse just fine. I end up with the same
enum on the client. Also beware that the values will not be the same, but
they don't need to be since the enum name is all that matters in the realm
of XML.

HTH,
Drew

Nov 21 '05 #3
Drew - What is the [Flags] bit for ? Am writing my web service in
VB.Net...what would the equivalent for it? Cannot find any reference in MSDN.

Thanks.

"Drew Marsh" wrote:
DMitchell wrote:
Is there any way of getting a public enumeration to be generated into
a web service proxy?


This works for me:

<codeSnippet language="C#">
[Flags]
public enum TestEnum
{
None = 0,
Value1 = 1,
Value2 = 2
}

[WebMethod]
public TestEnum ReturnEnum()
{
return TestEnum.None;
}
</codeSnippet>

It generates the following Schmea within the WSDL:

<s:simpleType name="TestEnum" >
<s:list>
<s:simpleType >
<s:restrictio n base="s:string" >
<s:enumeratio n value="None" />
<s:enumeratio n value="Value1" />
<s:enumeratio n value="Value2" />
</s:restriction>
</s:simpleType>
</s:list>
</s:simpleType>

Which the proxy generator seems to parse just fine. I end up with the same
enum on the client. Also beware that the values will not be the same, but
they don't need to be since the enum name is all that matters in the realm
of XML.

HTH,
Drew

Nov 21 '05 #4
DMitchell wrote:
Drew - What is the [Flags] bit for ? Am writing my web service in
VB.Net...what would the equivalent for it? Cannot find any reference
in MSDN.


Oh, you might not need that. It's short for FlagsAttribute which you can
read about here[1]. If you don't need bitwise enums, then you don't need
the attribute. Even without that attribute applied to my enum, it works.
Enums are a well supported concept in Microsoft's web services tools.

HTH,
Drew

[1] http://msdn.microsoft.com/library/en...eclasstopic.as

Nov 21 '05 #5
On 29/11/2004, around 09:29, Drew Marsh wrote:

<delurk>
Drew, thanks for that. Something I didn't know and can definitely use.

DM> http://msdn.microsoft.com/library/en...classtopic.asp
</delurk>

--
Stuart
See headers for PGP Key.
The darkest hour is just before dawn. So if you're going to steal your
neighbour's milk, that's the time to do it.

Nov 21 '05 #6

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

Similar topics

2
7170
by: hazz | last post by:
I don't get it. I have a VS2005 solution with a web service project and a windows project. The web service when tested on its own works fine. But when I add it as a web reference and refer to it my windows form code behind I receive the following; {"The request failed with HTTP status 401: Unauthorized."} when trying to execute this.dataGridView1.DataSource = ws.ReturnStudentDS(); not sure if it is relevant but the web.config in the...
4
1411
by: hogcods | last post by:
I'm having a strange problem with a service I developed. After installing the service on the target machine, I'm trying to start it using the Services admin window. I get the "Windows is starting" status window, but it times out - even though the application's log file says that it did start. The service's OnStart event spawns a thread and exits - that's all! I even tried it with no code in the OnStart event and get the same thing. The service...
14
1910
by: needin4mation | last post by:
I have this in my web service: public XmlDocument GetDataFromDB(string name) { .... do some stuff with name variable..on the database... return the XmlDocument to my datagrid; } Now, in my client default.aspx I have a button that calls this
6
3995
by: Joseph Geretz | last post by:
I have the following class which I am serializing and passing back and forth between my Web Service application and the client. public class Token : SoapHeader { public string SID; public string UID; public string PWD; }
0
2368
by: =?Utf-8?B?QW5keSBZdQ==?= | last post by:
Hi, I'm trying to return exceptions from a WCF Service using FaultExceptions. I got the service compiled and running. But I get an error while adding a service reference to it. The error reads: " Attempting to download metadata from 'http://localhost:4619/WCFService1/Service.svc' using WS-Metadata Exchange or DISCO. Error: Cannot import wsdl:portType Detail: An exception was thrown while running a WSDL import extension:
3
2054
by: elh.maayan | last post by:
hi... i'm trying to use axis2 to call a dotnet web service.. public class Service : System.Web.Services.WebService { public Service () {} public string HelloWorld() { return "Hello World"; }
20
6758
by: =?Utf-8?B?cmtibmFpcg==?= | last post by:
I was executing the steps given in http://suppor.microsoft.com/kb/308359 for testing a sample web service application. However, the following line gives a compilation error: localhost.Service1 xxx = new localhost.Service1(); localhost is not recognized by the compiler.
1
4856
by: SwapnilD | last post by:
I'm creating a webservice in vb.net version 2.0 on my local machine, deploying it to v1.1 on development server and getting an error "Could not create type 'Service'." Below is the code snippet that I wrote to create a web service - Service.asmx file <%@ WebService Language="vb" CodeBehind="~/App_Code/Service.vb" Class="Service"%> - Service.vb file in "App_Code" folder WebService(Namespace:="http://www.abc.com/Service")> _
0
1177
by: tookerello | last post by:
hi how can i view the the web service result in my client app? the web service is: public struct SecurityInfo { public string location; public string areacode; }
0
9800
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
11181
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...
0
10778
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10439
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9597
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7990
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
7148
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
6014
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3252
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.