Re: Using Enum type as Webservice Parameter

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



{\rtf1\ansi\ansicpg936\deff0\deflang1033\deflangfe2052{\fonttbl{\f0\fnil\fprq2\fcharset0 MS Sans Serif;}}
\viewkind4\uc1\pard\lang2052\f0\fs20 Hi Martin,
\par
\par As Martin Kulov mentioned, generally enum types are represented by xsd enumeration simple type like below:
\par
\par <s:simpleType name="TestEnum">
\par - <s:restriction base="s:string">
\par <s:enumeration value="A" />
\par <s:enumeration value="B" />
\par </s:restriction>
\par </s:simpleType>
\par
\par so it can not hold two value pairs(or the mapping info). For your scenario,I think you can consider use the XmlEnumAttribute to
\par specify the enum's actual number value as the underlying xmlserialization value. e.g:
\par
\par =================
\par Public Enum TestEnum As Integer
\par
\par <XmlEnum("128")> _
\par Enum1 = 128
\par
\par <XmlEnum("256")> _
\par Enum2 = 256
\par
\par End Enum
\par ====================
\par
\par 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.
\par
\par Hope this helps.
\par
\par Regards,
\par
\par Steven Cheng
\par Microsoft Online Community Support
\par
\par
\par ==================================================
\par
\par When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue.
\par
\par ==================================================
\par
\par
\par This posting is provided "AS IS" with no warranties, and confers no rights.
\par
\par
\par
\par Get Secure! www.microsoft.com/security
\par (This posting is provided "AS IS", with no warranties, and confers no rights.)
\par
\par
\par
\par }

Relevant Pages

  • Re: Enum Problems
    ... passing enum types - during wsdl and everywhere on its way it is passed ... as string. ... this enum type to webservice. ... public enum StatusType ...
    (microsoft.public.dotnet.framework.aspnet.webservices)
  • Re: forward declaration of an enumerated type
    ... No matter struct and enum types can be forwarded declared. ... void print(X& x, ENU enu); ...
    (microsoft.public.vc.language)
  • Re: C DLL to C# (types exporting)
    ... I've got a DLL written in C convention. ... There're a few of enum types that ... Make your C source file look like so: ... enum anenum { ...
    (microsoft.public.dotnet.languages.csharp)
  • Casting as an enum type
    ... I've got three enum types: ... private void func ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: flag operator questions
    ... If I want to group a number of these rights into a role, ... > determine the xor result of all the rights that i need? ... unless I gave the enum a smaller type. ... > Public Enum Security ...
    (microsoft.public.dotnet.languages.vb)