Groups | Blog | Home
all groups > dotnet web services > april 2006 >

dotnet web services : Serialization issue



Rucha
4/5/2006 4:23:01 AM
We are using ACAServices in our project, and are passing entity classes as
parameters to the ACAServiceMethod. We are using a private variable
entityState to indicate whether the entity is new/updated and so on. At
present we are not using any custom serialization in our project, we just
decorate the entity class with “Serializable” attribute as shown below:



[Serializable]

public class Address

{

private string _street;

private string _city;

private entityState;

public string Street

{

get { return _street; }

set

{

if (_street != value)

{

this.entityState = “modified”;

}

_street = value;

}

}



When this ACAServiceMethod is called, deserialization happens. Taking above
entity as a sample, when deserialization occurs, street is null and value is
suppose “WALL STREET”, then the if condition is satisfied and the entityState
property always gets set to “modified”. We wish to maintain the state of the
object as it was stored during serialization.



We are aware that there is some way by which we can decorate a web service
with certain attributes. These attributes force the ACAService to implement
custom serialization / deserialization methods. However we are not able to
find any documentation which gives exact implementation details.

Let me elaborate a little more on our entity class design. In our case, we
have an EntityBase class, which contains properties such as ID and so on. All
the entities inherit from the EntityBase class. The entityState mentioned
below is actually part of our EntityBase class.

Does anyone have a sample for implementing this, or any other solution for
this problem?
guybar
4/6/2006 2:19:02 AM
The problem is there is now way to serialize a private field. The
serialization process of the webservices usses reflection to go over all of
the entity public fields and serialize them. reflection cannot access the
values of private fields so you cannot use any of the serialization
attributes to force the serialization of your state field. I'm attaching a
link to an artical that explains all of the attributes of xml serialization
which is used in web services:
http://www.topxml.com/xmlserializer/serializer.pdf
--
GuyBar


[quoted text, click to view]
AddThis Social Bookmark Button