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

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 12505
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:restriction base="s:string">
<s:enumeration value="None" />
<s:enumeration value="Value1" />
<s:enumeration 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:restriction base="s:string">
<s:enumeration value="None" />
<s:enumeration value="Value1" />
<s:enumeration 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:restriction base="s:string">
<s:enumeration value="None" />
<s:enumeration value="Value1" />
<s:enumeration 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
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...
4
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"...
14
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...
6
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...
0
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: "...
3
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
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...
1
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...
0
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
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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...

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.