A default XmlSerializer
(automatically provided by Visual Studio) is used with my web service. I'm only using attributes to mark methods [WebMethod]
and objects [Serialize()]
, etc.
There is an object passed in both directions between the web service and a client.
One of the members (public MyClassType MyClass
;) of this object is meant to be single direction, one time only value sent to the client. If the client returns this member set, I want my web service to not deserialize it so that the deserialized object contains a null
value for that member.
Did some research and if I were using non XmlSerializer
, then I could attach a "OnDeserialization
" attribute to a method within the object that would achieve what I need.
I'm trying to avoid this potential scenario. Web service sends the object to the client with the member set. The client acts on the member as it should. The client sends back the object with the member not cleared (NULLed) because it forgot. The web service does some additional work and sends the same object back (maybe slightly modified), but the member's value was not changed and therefore is no longer current and the client should see a NULL value for it to prevent the client from acting on this unchanged member again. The web service could set a new value for the member which the client should act on again.
Is there a similarly easy way to do this for XmlSerializer
?