Hi All,
Is there a way while exposing a web service, I can mark some of the properties in object as immutable or read-only ?
Thanks
Hi All,
Is there a way while exposing a web service, I can mark some of the properties in object as immutable or read-only ?
Thanks
There's nothing special about web services in this regard. If your data object is immutable on the server side, and is deserialised as an immutable class on the client side, then no-one will be able to modify the properties.
What is your motivation for this, though? Making something immutable from the client's perspective is mainly for their convenience rather than any kind of security/correctness from your server's implementation. If they make modifications to their version of an object, it will not affect yours as they are distinct. Thus if your concern is that you want to expose e.g. the server config parameters, without them being able to change them, then simply go ahead - the serialisation/deserialisation process means they get a copy of your object, not a reference to the object itself.
(Note that if you're using remote object sharing such as RMI or Terracotta then the above paragraph may not be true, but then that's not really web services in the classical sense).