I find Inheritance and the concept of a base class as the strongest point of OOP.
Do not overestimate the power of inheritance - almost all GoF templates avoid the misuse of inheritance.
But this is not recommended in SOA.
No, this is not encouraged at all. What for? Because in SOA, you have a service that provides some operations. The service itself is determined by the description of the service (contract / interface). In the case of a contract with a SOAP service, it is described in WSDL. If you need to have another service providing the same set of operations with slightly different behavior, you simply implement the interface again and the target client for the new service (by providing a new endpoint URL). Thus, inheritance with a service contract "works", but it does not work exactly the same with data contracts.
Each overhead operation usually takes some data and returns some data. This data is again described in the service description. In the case of SOAP service data, the data is described as XSD. When you send data from the client to the service (or in the opposite direction), the data must be serialized and the recipient should be able to deserialize it (if you do not want to work with SOAP envelopes directly or if you do not want to use xsd: any = untyped XML as received data). If you want to use inheritance in a data contract, you must somehow include information about derivative contracts in the service description. Only after including this information in the description of the service can you inform consumers of the existence of inherited data contracts (they need this information to work with derived types).
WCF offers the ability to work with legacy data contracts. You can use the KnownTypeAttribute , ServiceKnownTypeAttribute attribute or DataContractResolver . You can also check out this great article for more details.
In the case of incompatible and closely related systems (without SOA), you can also use the NetDataContractSerializer , which allows you to use inheritance without any because each serialized message contains information about the type of CLR needed for deserialization, and clients with the service must share the data collection.
source share