Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / November 2004

Tip: Looking for answers? Try searching our database.

Public Enums in Web service

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DMitchell - 29 Nov 2004 15:09 GMT
Is there any way of getting a public enumeration to be generated into a web
service proxy?
Drew Marsh - 29 Nov 2004 15:31 GMT
> 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
DMitchell - 29 Nov 2004 15:49 GMT
Thanks Drew. Have tried that and just does not generate anything into the
proxy. Will try on another machine.

> > Is there any way of getting a public enumeration to be generated into
> > a web service proxy?
[quoted text clipped - 38 lines]
> HTH,
> Drew
DMitchell - 29 Nov 2004 16:09 GMT
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.

> > Is there any way of getting a public enumeration to be generated into
> > a web service proxy?
[quoted text clipped - 38 lines]
> HTH,
> Drew
Drew Marsh - 29 Nov 2004 16:44 GMT
> 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-us/cpref/html/frlrfsystemflagsattributeclas
stopic.as

Stuart Hemming (via DFN-CIS NetNews Service) - 30 Nov 2004 09:31 GMT
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-us/cpref/html/frlrfsystemflagsattributeclas
stopic.asp

</delurk>

Signature

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.


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.