WCF - How to use IDataSurrogate to exclude the data member depends on client requirement -


I have a data contract with 6 properties. A customer needs the first 3 properties and the other client needs the last 3 properties of data contracts. How to write a data contract in the service so that the service only send messages with the necessary properties?

The right way to do this is to create a separate service for each customer. Using their own data contract will expose the operation. Both services will be completely wrapped around your original argument that works with data objects. If the reason of sending only the lowest subset of properties is data security, then creating two services is the only legitimate option.

If we consider more information about this, then here is a description of the problem in the service description. If you expose Metadata / WSDL on your service then there will always be an entire data contract because you can not change it dynamically. If a client creates a proxy from these metadata, then this entire agreement will also be received.

If you configure your contract and do not set it in your service then you can not send some properties to the SOAP message, but I do not think this is a good solution.

Comments