By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,932 Members | 1,291 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,932 IT Pros & Developers. It's quick & easy.

How to Serialize read-Only Properties?

P: n/a
Hi all,
I am using a certain class as part of a return of a soap service. The
readonly properties are not serialized in the soap response.

Is there a simple way to force them being serialized?

Thanks

Armin
Nov 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
The short answer is that you can't. If you have:

Public Class MyClass
Public ReadOnly Property Name() As String
Get
Return m_name
End Get
End Property
End Class

Theoritically, this could be serialized into a SOAP message, but then what
happens on the other end? It would have to de-serialize this by creating an
instance of MyClass, and then try to set the Name property with data from
the SOAP message. However, it can't set the Name property on the client
side because it's read only.

You could make a "do nothing" set section for the property, and that would
let it serialize, but data would be lost when it's deserialized on the other
end. You could also make a Set section that throws an exception if it's
called. Then, it would be impossible to externally set the property on the
server side, but it would serialize and deserialize fine (the client side
wouldn't automatically have the Set that throws an exception). However, the
property on the client side would not be read-only.

HTH,
Scott Swigart
"Armin Braun" <Ar*********@dlr.de> wrote in message
news:2v*************@uni-berlin.de...
Hi all,
I am using a certain class as part of a return of a soap service. The
readonly properties are not serialized in the soap response.

Is there a simple way to force them being serialized?

Thanks

Armin

Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.