Controling Object Serialization
|
| Controling Object Serialization | I have a user object that I am using in two areas, natively in the application and in a web service. The object is fairly simple, ie
class user { private string myFirstName; public string FirstName { get; set} ... } however, I have parts of this class that I do not want exposed in the web service, so I have added the [SoapIgnore] attribute. [SoapIgnore] private string myLocalOnly; public string LocalOnly
}
I thought this would remove properties with the setting from the service definition of the Web Service, but this does not appear to be the case. I also tried the [NonSerialized] attribute, but that is not allowed on a property. So my question, is it possible to use the same object, but have some of the public properties hidden in the soap definition by user the serialization attributes?
Thanks ;)
Kurt
Beak2001
| | I found that adding the [XmlIgnore] attribue acheived the results I was hpoing for, but I not clear what the [SoapIgnore] attribute actually does..
Thansk for the reply,
Kurt
"Altaf Al-Amin Najwani" wrote:
> apply nonserialize attribute on mylocalonly variable. This attribute is > applicable on field variables only. > > "Beaker" wrote: > > I have a user object that I am using in two areas, natively in the > > application and in a web service. The object is fairly simple, ie > > > > class user > > { > > private string myFirstName; > > public string FirstName > > { get; set} > > ... > > } > > however, I have parts of this class that I do not want exposed in the web > > service, so I have added the [SoapIgnore] attribute. > > [SoapIgnore] > > private string myLocalOnly; > > public string LocalOnly > > I thought this would remove properties with the setting from the service > > definition of the Web Service, but this does not appear to be the case. I > > also tried the [NonSerialized] attribute, but that is not allowed on a > > property. So my question, is it possible to use the same object, but have > > some of the public properties hidden in the soap definition by user the > > serialization attributes? > > Thanks ;) > > Kurt > > Beak2001
|
|
|
|
|
 | Members Area | |
|
 | Last Web Marketing |
|
|
|
|
 | Last Programming Tips |
|
|
|
|
 | Last News |
|
|
|
|
|
|