all groups > dotnet xml > february 2007 >
You're in the

dotnet xml

group:

Passing Static Text Between Client and Server


Passing Static Text Between Client and Server Mike
2/21/2007 10:34:03 AM
dotnet xml: I have a list of static text that I want the client and server to be able to
share such that I don't have to hard-code the text on both sides. The client
communicates with the server via web services.

How do I set this up so that both sides can simply refer to the the same text?

I tried a struct with static properties, it works on the server but there is
no reference on the client side to the static properties. There's a
reference to the struct but not the properties.

Ex:
public struct StatusType
{
public static string Accepted
{
get { return "Accepted"; }
}
public static string Rejected
{
get { return "Rejected"; }
}
public static string OnHold
{
get { return "On Hold"; }
}
}

It works when I do something similar with enums, but I need to refer to the
actual text such as "On Hold".

Re: Passing Static Text Between Client and Server Mike
2/26/2007 2:28:17 PM
So for your second option, would I have to put the public const String
Accepted in a class that is return by some method or can I put it in its own
class? If it's in its own class, how will wsdl know to include it in the
proxy? Or do all public const's automatically get included?

Thank you


[quoted text, click to view]
Re: Passing Static Text Between Client and Server Keith Patrick
2/26/2007 4:15:22 PM
You can put the struct into a separate project & have both client and server
each reference the common assembly.
Also, the normal practice for declaring constants is to go ahead and use
fields (one of the few places where public fields are OK):
public const String Accepted (const is implied to be static)


Re: Passing Static Text Between Client and Server Keith Patrick
2/28/2007 11:10:37 AM
If you're encapsulating your constants as a struct, then merely referencing
it in your project and using it in your web method will tell the WSDL to
define it. Your web client might try to make a proxy version of your struct
in the References.cs file, so you have to make sure you mark your struct
with XmlRoot("your web service's namespace") so that the code generation
tool uses the one that is already referenced by both projects instead of
creating a new one for the client


AddThis Social Bookmark Button