By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,743 Members | 1,072 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,743 IT Pros & Developers. It's quick & easy.

How can I expose constant values to my clients?

P: n/a
I have some constant values in my web service that my client application will
require. Having to keep server side and client side definitions insync is
tedious. I am trying to do something like this:

[FlagsAttribute]
public __value enum Colors { Red = 1, Green = 2, Blue = 4, Yellow = 8 };

However, the resulting wsdl omits the actual flag values:

- <s:simpleType name="Colors">
- <s:list>
- <s:simpleType>
- <s:restriction base="s:string">
<s:enumeration value="Yellow" />
<s:enumeration value="Blue" />
<s:enumeration value="Green" />
<s:enumeration value="Red" />
</s:restriction>
</s:simpleType>
</s:list>
</s:simpleType>
So the client side stub generation (java client) just creates a class with
strings. The actual integer values are required to be of any use.

Help apprectiated, thanks.

Nov 23 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
What you want to do is tag your enums in your implementation so that the
string values on the wire will be promoted to the values you expect in your
code. The serializer will automatically do this for you.

For example, you get what you want if you do the following:

[Serializable]
public enum SpeakerStatus
{
[XmlEnum(Name="approved")] approved = 1,
[XmlEnum(Name="proposed")] proposed = 2,
[XmlEnum(Name="reviewed")] reviewed = 4,
[XmlEnum(Name="tired")] tired = 8,
[XmlEnum(Name="drunk")] drunk = 16
}

I hope this helps

Dan Rogers
Microsoft Corporation

--------------------
Thread-Topic: How can I expose constant values to my clients?
thread-index: AcTnpypktuL3u9nlSGSLLDMuwmRaqA==
X-WBNR-Posting-Host: 64.91.117.139
From: =?Utf-8?B?Y2lwaGVy?= <ci****@discussions.microsoft.com>
Subject: How can I expose constant values to my clients?
Date: Tue, 21 Dec 2004 13:51:03 -0800
Lines: 28
Message-ID: <E2**********************************@microsoft.co m>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.dotnet.framework.webservices
NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.webservices:8254
X-Tomcat-NG: microsoft.public.dotnet.framework.webservices

I have some constant values in my web service that my client application
will
require. Having to keep server side and client side definitions insync is
tedious. I am trying to do something like this:

[FlagsAttribute]
public __value enum Colors { Red = 1, Green = 2, Blue = 4, Yellow = 8 };

However, the resulting wsdl omits the actual flag values:

- <s:simpleType name="Colors">
- <s:list>
- <s:simpleType>
- <s:restriction base="s:string">
<s:enumeration value="Yellow" />
<s:enumeration value="Blue" />
<s:enumeration value="Green" />
<s:enumeration value="Red" />
</s:restriction>
</s:simpleType>
</s:list>
</s:simpleType>
So the client side stub generation (java client) just creates a class with
strings. The actual integer values are required to be of any use.

Help apprectiated, thanks.
Nov 23 '05 #2

P: n/a
I'm using managed C++ and get this with your code:

error C2337: 'XmlEnum' : attribute not found; it is neither a built-in nor a
custom attribute that is accessible in the current namespace

"Dan Rogers" wrote:
What you want to do is tag your enums in your implementation so that the
string values on the wire will be promoted to the values you expect in your
code. The serializer will automatically do this for you.

For example, you get what you want if you do the following:

[Serializable]
public enum SpeakerStatus
{
[XmlEnum(Name="approved")] approved = 1,
[XmlEnum(Name="proposed")] proposed = 2,
[XmlEnum(Name="reviewed")] reviewed = 4,
[XmlEnum(Name="tired")] tired = 8,
[XmlEnum(Name="drunk")] drunk = 16
}

I hope this helps

Dan Rogers
Microsoft Corporation

--------------------
Thread-Topic: How can I expose constant values to my clients?
thread-index: AcTnpypktuL3u9nlSGSLLDMuwmRaqA==
X-WBNR-Posting-Host: 64.91.117.139
From: =?Utf-8?B?Y2lwaGVy?= <ci****@discussions.microsoft.com>
Subject: How can I expose constant values to my clients?
Date: Tue, 21 Dec 2004 13:51:03 -0800
Lines: 28
Message-ID: <E2**********************************@microsoft.co m>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.dotnet.framework.webservices
NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.webservices:8254
X-Tomcat-NG: microsoft.public.dotnet.framework.webservices

I have some constant values in my web service that my client application
will
require. Having to keep server side and client side definitions insync is
tedious. I am trying to do something like this:

[FlagsAttribute]
public __value enum Colors { Red = 1, Green = 2, Blue = 4, Yellow = 8 };

However, the resulting wsdl omits the actual flag values:

- <s:simpleType name="Colors">
- <s:list>
- <s:simpleType>
- <s:restriction base="s:string">
<s:enumeration value="Yellow" />
<s:enumeration value="Blue" />
<s:enumeration value="Green" />
<s:enumeration value="Red" />
</s:restriction>
</s:simpleType>
</s:list>
</s:simpleType>
So the client side stub generation (java client) just creates a class with
strings. The actual integer values are required to be of any use.

Help apprectiated, thanks

Nov 23 '05 #3

P: n/a
nm, found the correct namespace. However, your code produces the exact same
wsdl as my original code, thus the stub generation is useless. aka no
integer values, just strings.

[Serializable]
public __value enum Colors
{
[XmlEnum(Name="Red")] Red = 1,
[XmlEnum(Name="Green")] Green = 2,
[XmlEnum(Name="Blue")] Blue = 4,
[XmlEnum(Name="Yellow")] Yellow = 8
};

produces...

- <s:simpleType name="Colors">
- <s:restriction base="s:string">
<s:enumeration value="Yellow" />
<s:enumeration value="Blue" />
<s:enumeration value="Green" />
<s:enumeration value="Red" />
</s:restriction>
</s:simpleType>
"cipher" wrote:
I'm using managed C++ and get this with your code:

error C2337: 'XmlEnum' : attribute not found; it is neither a built-in nor a
custom attribute that is accessible in the current namespace

"Dan Rogers" wrote:
What you want to do is tag your enums in your implementation so that the
string values on the wire will be promoted to the values you expect in your
code. The serializer will automatically do this for you.

For example, you get what you want if you do the following:

[Serializable]
public enum SpeakerStatus
{
[XmlEnum(Name="approved")] approved = 1,
[XmlEnum(Name="proposed")] proposed = 2,
[XmlEnum(Name="reviewed")] reviewed = 4,
[XmlEnum(Name="tired")] tired = 8,
[XmlEnum(Name="drunk")] drunk = 16
}

I hope this helps

Dan Rogers
Microsoft Corporation

--------------------
Thread-Topic: How can I expose constant values to my clients?
thread-index: AcTnpypktuL3u9nlSGSLLDMuwmRaqA==
X-WBNR-Posting-Host: 64.91.117.139
From: =?Utf-8?B?Y2lwaGVy?= <ci****@discussions.microsoft.com>
Subject: How can I expose constant values to my clients?
Date: Tue, 21 Dec 2004 13:51:03 -0800
Lines: 28
Message-ID: <E2**********************************@microsoft.co m>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.dotnet.framework.webservices
NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.webservices:8254
X-Tomcat-NG: microsoft.public.dotnet.framework.webservices

I have some constant values in my web service that my client application
will
require. Having to keep server side and client side definitions insync is
tedious. I am trying to do something like this:

[FlagsAttribute]
public __value enum Colors { Red = 1, Green = 2, Blue = 4, Yellow = 8 };

However, the resulting wsdl omits the actual flag values:

- <s:simpleType name="Colors">
- <s:list>
- <s:simpleType>
- <s:restriction base="s:string">
<s:enumeration value="Yellow" />
<s:enumeration value="Blue" />
<s:enumeration value="Green" />
<s:enumeration value="Red" />
</s:restriction>
</s:simpleType>
</s:list>
</s:simpleType>
So the client side stub generation (java client) just creates a class with
strings. The actual integer values are required to be of any use.

Help apprectiated, thanks

Nov 23 '05 #4

P: n/a
Hi,

The stub isn't required to have the flag values. What this markup does is
define the mapping between the XML on the wire and the enum in your code.
Thus, it's ok that the proxy code that is generated actually gets the
string values. What is important is that you get the flags you want in
your server side code.

The issue you will probably face is if you intended these flags to be used
additively. In that case, you will want to make the field an integer
(since there is no enum for the additive values), and define your flags as
enums that are in an assembly that you share privately with the client.
There is no equivalent in XML for flag addition - so since you're dealing
with an XML wire contract, you have to adjust your design so that you
aren't imposing client side implementation details thru your contract.

I hope this helps

Dan Rogers
Microsoft Corporation
--------------------
Thread-Topic: How can I expose constant values to my clients?
thread-index: AcToNNOx19Ds5+ZuRI6wM9GkJN+yhA==
X-WBNR-Posting-Host: 64.91.117.139
From: =?Utf-8?B?Y2lwaGVy?= <ci****@discussions.microsoft.com>
References: <E2**********************************@microsoft.co m>
<AW**************@cpmsftngxa10.phx.gbl>
<E4**********************************@microsoft.co m>
Subject: RE: How can I expose constant values to my clients?
Date: Wed, 22 Dec 2004 06:45:06 -0800
Lines: 110
Message-ID: <14**********************************@microsoft.co m>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.dotnet.framework.webservices
NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.webservices:8265
X-Tomcat-NG: microsoft.public.dotnet.framework.webservices

nm, found the correct namespace. However, your code produces the exact
same
wsdl as my original code, thus the stub generation is useless. aka no
integer values, just strings.

[Serializable]
public __value enum Colors
{
[XmlEnum(Name="Red")] Red = 1,
[XmlEnum(Name="Green")] Green = 2,
[XmlEnum(Name="Blue")] Blue = 4,
[XmlEnum(Name="Yellow")] Yellow = 8
};

produces...

- <s:simpleType name="Colors">
- <s:restriction base="s:string">
<s:enumeration value="Yellow" />
<s:enumeration value="Blue" />
<s:enumeration value="Green" />
<s:enumeration value="Red" />
</s:restriction>
</s:simpleType>
"cipher" wrote:
I'm using managed C++ and get this with your code:

error C2337: 'XmlEnum' : attribute not found; it is neither a built-in nor a custom attribute that is accessible in the current namespace

"Dan Rogers" wrote:
What you want to do is tag your enums in your implementation so that the string values on the wire will be promoted to the values you expect in your code. The serializer will automatically do this for you.

For example, you get what you want if you do the following:

[Serializable]
public enum SpeakerStatus
{
[XmlEnum(Name="approved")] approved = 1,
[XmlEnum(Name="proposed")] proposed = 2,
[XmlEnum(Name="reviewed")] reviewed = 4,
[XmlEnum(Name="tired")] tired = 8,
[XmlEnum(Name="drunk")] drunk = 16
}

I hope this helps

Dan Rogers
Microsoft Corporation

--------------------
Thread-Topic: How can I expose constant values to my clients?
thread-index: AcTnpypktuL3u9nlSGSLLDMuwmRaqA==
X-WBNR-Posting-Host: 64.91.117.139
From: =?Utf-8?B?Y2lwaGVy?= <ci****@discussions.microsoft.com>
Subject: How can I expose constant values to my clients?
Date: Tue, 21 Dec 2004 13:51:03 -0800
Lines: 28
Message-ID: <E2**********************************@microsoft.co m>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.dotnet.framework.webservices
NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.webservices:8254
X-Tomcat-NG: microsoft.public.dotnet.framework.webservices

I have some constant values in my web service that my client application will
require. Having to keep server side and client side definitions insync is tedious. I am trying to do something like this:

[FlagsAttribute]
public __value enum Colors { Red = 1, Green = 2, Blue = 4, Yellow = 8 };
However, the resulting wsdl omits the actual flag values:

- <s:simpleType name="Colors">
- <s:list>
- <s:simpleType>
- <s:restriction base="s:string">
<s:enumeration value="Yellow" />
<s:enumeration value="Blue" />
<s:enumeration value="Green" />
<s:enumeration value="Red" />
</s:restriction>
</s:simpleType>
</s:list>
</s:simpleType>
So the client side stub generation (java client) just creates a class with strings. The actual integer values are required to be of any use.

Help apprectiated, thanks


Nov 23 '05 #5

P: n/a
Thanks, I guess I'll have to adjust my design or keep some client/server
constants insync manually.

"Dan Rogers" <da***@microsoft.com> wrote in message
news:vD**************@cpmsftngxa10.phx.gbl...
Hi,

The stub isn't required to have the flag values. What this markup does is
define the mapping between the XML on the wire and the enum in your code.
Thus, it's ok that the proxy code that is generated actually gets the
string values. What is important is that you get the flags you want in
your server side code.

The issue you will probably face is if you intended these flags to be used
additively. In that case, you will want to make the field an integer
(since there is no enum for the additive values), and define your flags as
enums that are in an assembly that you share privately with the client.
There is no equivalent in XML for flag addition - so since you're dealing
with an XML wire contract, you have to adjust your design so that you
aren't imposing client side implementation details thru your contract.

I hope this helps

Dan Rogers
Microsoft Corporation
--------------------
Thread-Topic: How can I expose constant values to my clients?
thread-index: AcToNNOx19Ds5+ZuRI6wM9GkJN+yhA==
X-WBNR-Posting-Host: 64.91.117.139
From: =?Utf-8?B?Y2lwaGVy?= <ci****@discussions.microsoft.com>
References: <E2**********************************@microsoft.co m>
<AW**************@cpmsftngxa10.phx.gbl>
<E4**********************************@microsoft.co m>
Subject: RE: How can I expose constant values to my clients?
Date: Wed, 22 Dec 2004 06:45:06 -0800
Lines: 110
Message-ID: <14**********************************@microsoft.co m>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.dotnet.framework.webservices
NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.webservices:8265
X-Tomcat-NG: microsoft.public.dotnet.framework.webservices

nm, found the correct namespace. However, your code produces the exact
same
wsdl as my original code, thus the stub generation is useless. aka no
integer values, just strings.

[Serializable]
public __value enum Colors
{
[XmlEnum(Name="Red")] Red = 1,
[XmlEnum(Name="Green")] Green = 2,
[XmlEnum(Name="Blue")] Blue = 4,
[XmlEnum(Name="Yellow")] Yellow = 8
};

produces...

- <s:simpleType name="Colors">
- <s:restriction base="s:string">
<s:enumeration value="Yellow" />
<s:enumeration value="Blue" />
<s:enumeration value="Green" />
<s:enumeration value="Red" />
</s:restriction>
</s:simpleType>
"cipher" wrote:
I'm using managed C++ and get this with your code:

error C2337: 'XmlEnum' : attribute not found; it is neither a built-in nor a
custom attribute that is accessible in the current namespace

"Dan Rogers" wrote:
What you want to do is tag your enums in your implementation so that the string values on the wire will be promoted to the values you expect in your code. The serializer will automatically do this for you.

For example, you get what you want if you do the following:

[Serializable]
public enum SpeakerStatus
{
[XmlEnum(Name="approved")] approved = 1,
[XmlEnum(Name="proposed")] proposed = 2,
[XmlEnum(Name="reviewed")] reviewed = 4,
[XmlEnum(Name="tired")] tired = 8,
[XmlEnum(Name="drunk")] drunk = 16
}

I hope this helps

Dan Rogers
Microsoft Corporation

--------------------
Thread-Topic: How can I expose constant values to my clients?
thread-index: AcTnpypktuL3u9nlSGSLLDMuwmRaqA==
X-WBNR-Posting-Host: 64.91.117.139
From: =?Utf-8?B?Y2lwaGVy?= <ci****@discussions.microsoft.com>
Subject: How can I expose constant values to my clients?
Date: Tue, 21 Dec 2004 13:51:03 -0800
Lines: 28
Message-ID: <E2**********************************@microsoft.co m>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.dotnet.framework.webservices
NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.webservices:8254
X-Tomcat-NG: microsoft.public.dotnet.framework.webservices

I have some constant values in my web service that my client application will
require. Having to keep server side and client side definitions
insync is tedious. I am trying to do something like this:

[FlagsAttribute]
public __value enum Colors { Red = 1, Green = 2, Blue = 4, Yellow =
8
};
However, the resulting wsdl omits the actual flag values:

- <s:simpleType name="Colors">
- <s:list>
- <s:simpleType>
- <s:restriction base="s:string">
<s:enumeration value="Yellow" />
<s:enumeration value="Blue" />
<s:enumeration value="Green" />
<s:enumeration value="Red" />
</s:restriction>
</s:simpleType>
</s:list>
</s:simpleType>
So the client side stub generation (java client) just creates a class with strings. The actual integer values are required to be of any use.

Help apprectiated, thanks

Nov 23 '05 #6

P: n/a
Hi,

Yes, if you intend for the caller to add enums and achieve a net value
(that itself is not in the enum space), make the data passed an integer,
and share the assembly with intended callers - and document the field in
the service specification (you were planning on writing one yes?) for
callers that are on other platforms.

I hope this helps

Dan Rogers
Microsoft Corporation
--------------------
From: "cipher" <fo**@yahoo.com>
References: <E2**********************************@microsoft.co m>
<AW**************@cpmsftngxa10.phx.gbl>
<E4**********************************@microsoft.co m>
<14**********************************@microsoft.co m>
<vD**************@cpmsftngxa10.phx.gbl>
Subject: Re: How can I expose constant values to my clients?
Date: Wed, 22 Dec 2004 14:39:56 -0700
Lines: 176
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
Message-ID: <u3**************@TK2MSFTNGP15.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.webservices
NNTP-Posting-Host: adsl-64-91-117-139-rb2.ka.centurytel.net 64.91.117.139
Path:
cpmsftngxa10.phx.gbl!TK2MSFTNGXA01.phx.gbl!cpmsftn gxa06.phx.gbl!TK2MSFTNGP08
.phx.gbl!TK2MSFTNGP15.phx.gbl
Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.webservices:8273
X-Tomcat-NG: microsoft.public.dotnet.framework.webservices

Thanks, I guess I'll have to adjust my design or keep some client/server
constants insync manually.

"Dan Rogers" <da***@microsoft.com> wrote in message
news:vD**************@cpmsftngxa10.phx.gbl...
Hi,

The stub isn't required to have the flag values. What this markup does is
define the mapping between the XML on the wire and the enum in your code.
Thus, it's ok that the proxy code that is generated actually gets the
string values. What is important is that you get the flags you want in
your server side code.

The issue you will probably face is if you intended these flags to be used
additively. In that case, you will want to make the field an integer
(since there is no enum for the additive values), and define your flags as
enums that are in an assembly that you share privately with the client.
There is no equivalent in XML for flag addition - so since you're dealing
with an XML wire contract, you have to adjust your design so that you
aren't imposing client side implementation details thru your contract.

I hope this helps

Dan Rogers
Microsoft Corporation
--------------------
Thread-Topic: How can I expose constant values to my clients?
thread-index: AcToNNOx19Ds5+ZuRI6wM9GkJN+yhA==
X-WBNR-Posting-Host: 64.91.117.139
From: =?Utf-8?B?Y2lwaGVy?= <ci****@discussions.microsoft.com>
References: <E2**********************************@microsoft.co m>
<AW**************@cpmsftngxa10.phx.gbl>
<E4**********************************@microsoft.co m>
Subject: RE: How can I expose constant values to my clients?
Date: Wed, 22 Dec 2004 06:45:06 -0800
Lines: 110
Message-ID: <14**********************************@microsoft.co m>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.dotnet.framework.webservices
NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.webservices:8265
X-Tomcat-NG: microsoft.public.dotnet.framework.webservices

nm, found the correct namespace. However, your code produces the exact
same
wsdl as my original code, thus the stub generation is useless. aka no
integer values, just strings.

[Serializable]
public __value enum Colors
{
[XmlEnum(Name="Red")] Red = 1,
[XmlEnum(Name="Green")] Green = 2,
[XmlEnum(Name="Blue")] Blue = 4,
[XmlEnum(Name="Yellow")] Yellow = 8
};

produces...

- <s:simpleType name="Colors">
- <s:restriction base="s:string">
<s:enumeration value="Yellow" />
<s:enumeration value="Blue" />
<s:enumeration value="Green" />
<s:enumeration value="Red" />
</s:restriction>
</s:simpleType>
"cipher" wrote:
I'm using managed C++ and get this with your code:

error C2337: 'XmlEnum' : attribute not found; it is neither a built-in nor a
custom attribute that is accessible in the current namespace

"Dan Rogers" wrote:
What you want to do is tag your enums in your implementation so that the string values on the wire will be promoted to the values you expect in your code. The serializer will automatically do this for you.

For example, you get what you want if you do the following:

[Serializable]
public enum SpeakerStatus
{
[XmlEnum(Name="approved")] approved = 1,
[XmlEnum(Name="proposed")] proposed = 2,
[XmlEnum(Name="reviewed")] reviewed = 4,
[XmlEnum(Name="tired")] tired = 8,
[XmlEnum(Name="drunk")] drunk = 16
}

I hope this helps

Dan Rogers
Microsoft Corporation

--------------------
Thread-Topic: How can I expose constant values to my clients?
thread-index: AcTnpypktuL3u9nlSGSLLDMuwmRaqA==
X-WBNR-Posting-Host: 64.91.117.139
From: =?Utf-8?B?Y2lwaGVy?= <ci****@discussions.microsoft.com>
Subject: How can I expose constant values to my clients?
Date: Tue, 21 Dec 2004 13:51:03 -0800
Lines: 28
Message-ID: <E2**********************************@microsoft.co m>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.dotnet.framework.webservices
NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
Path: cpmsftngxa10.phx.gbl!TK2MSFTNGXA03.phx.gbl
Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.webservices:8254
X-Tomcat-NG: microsoft.public.dotnet.framework.webservices

I have some constant values in my web service that my client application will
require. Having to keep server side and client side definitions
insync is tedious. I am trying to do something like this:

[FlagsAttribute]
public __value enum Colors { Red = 1, Green = 2, Blue = 4, Yellow =
8
};
However, the resulting wsdl omits the actual flag values:

- <s:simpleType name="Colors">
- <s:list>
- <s:simpleType>
- <s:restriction base="s:string">
<s:enumeration value="Yellow" />
<s:enumeration value="Blue" />
<s:enumeration value="Green" />
<s:enumeration value="Red" />
</s:restriction>
</s:simpleType>
</s:list>
</s:simpleType>
So the client side stub generation (java client) just creates a class with strings. The actual integer values are required to be of any use.

Help apprectiated, thanks


Nov 23 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.