WCF is a message-based service β you serialize your message on one side, send it and receive on the other. You do not send objects, as you put it, you send only serialized messages. This is a very important difference!
Your server and client are completely separate - they do not share anything except the description of the service (a list of service methods), and the data is in the form of an XML schema.
What you get when you create a client is a proxy for the service methods and a copy of the data contract (it looks the same, but a different namespace, as a rule), which has the same signature in a serialized format. This is all there. You get a new separate client-side class that will serialize in the same format as your original server-side class.
This means: you get the same fields and properties - but that. Everything else (for example, implemented interfaces, .NET attributes, etc.) is not replicated. They cannot be - after all, WCF interacts - the client can be a PHP application or a Ruby program. How will they handle custom .NET attributes?
So, in short: everything that is specific to .NET and beyond the scope of simply presenting data based on an XML schema cannot be used in the WCF service.
There is a loopback hole - if you control both ends of the connection - both the server and the client - and both are .NET, then you can:
- put all your service contracts and data in a separate general assembly
- refers to this assembly in your server-side implementation of your service
- refer to this assembly in your side proxy
Using this, you will have one assembly with the same type on the server and on the client side - and with this "loophole" you can save .NET features such as attributes between the server and the client.
marc_s
source share