473,397 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

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.

class user
{
private string myFirstName;
public string FirstName
{ get; set}
...
[SoapIgnore]
private string myLocalOnly;
public string LocalOnly
{ get; set}

}

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
May 12 '06 #1
2 1383
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.

class user
{
private string myFirstName;
public string FirstName
{ get; set}
...
[SoapIgnore]
private string myLocalOnly;
public string LocalOnly
{ get; set}

}

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

May 14 '06 #2
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.

class user
{
private string myFirstName;
public string FirstName
{ get; set}
...
[SoapIgnore]
private string myLocalOnly;
public string LocalOnly
{ get; set}

}

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

May 14 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: NewToDotNet | last post by:
I am getting "Object reference not set to an instance of an object. " when I attempt to open a C# windows service class in design view, although I was able to initially create the service and open...
0
by: Philip Reed | last post by:
I'm trying to write a preferences-handling infrastructure that serializes prefs to XML. Basically I want to read in a common "default" prefs set, then read in the user's prefs and override the...
5
by: Mark Rae | last post by:
Hi, Can anyone please tell me how to convert an object say, a System.Web.Mail.MailMessage object, to a byte array and then convert the byte array to a Base64 string? Any assistance gratefully...
8
by: rawCoder | last post by:
Hi All, I need some advanced samples or references for passing custom objects over the network using sockets. Without using Remoting what are other options in .NET Framework for this binary...
5
by: David C. Allen | last post by:
I have a vb.net app that is controling excel 2000 thru the com interop interface. I have referenced the excel 9.0 library and have cut down the code in the problem subroutine to this: Dim...
5
by: Matthew | last post by:
I have a nice little Sub that saves data in a class "mySettings" to an XML file. I call it like so: Dim mySettings As mySettings = New mySettings mySettings.value1 = "someText" mySettings.value2...
1
by: J. Askey | last post by:
I am implementing a web service and thought it may be a good idea to return a more complex class (which I have called 'ServiceResponse') in order to wrap the original return value along with two...
0
by: anchiang | last post by:
Hi All, I have XML: <RegistryResponse status="Success" xmlns="urn:oasis:names:tc:ebxml-regrep:registry:xsd:2.1"> <AdhocQueryResponse xmlns="urn:oasis:names:tc:ebxml-regrep:query:xsd:2.1"> ...
3
by: Jeremy | last post by:
I've created a serializable class and put attributes around all the properties that should be serialized. I return the class from a web service, but my problem is that the wsdl for the web service...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.