Data Contracts in WCF

Simply, a data contract describes the data that is to be exchanged. That you know this is the one of the principles of Service-Oriented Architecture is policy-based compatibility. That section gave an example of a couple of strangers meeting on the street and wanting to start up a discussion. However, before these two strangers can start talking, they each need to agree on the “data” that they will be passing back and forth. This is a data contract. It is a formal agreement between the two parties that contains information regarding the data that they will be exchanging.
The important thing to remember is that the two parties don’t have to share the same data types to be able to start talking; they only need to share the same data contracts. The data contract specifically defines what each parameter and return type will be serialized/deserialized to and from (Binary and XML) in order be exchanged from one party to the other.
It is important to understand how serialization and deserialization apply to Windows Communication Foundation. Serialization is the act of taking structured data and converting it into a format that can be communicated or sent over a wire; for example, reading data from a database and converting it to a series of bytes to be sent over your network. Deserialization is the opposite. It takes the data coming in over the wire and converts it back to structured data.

Tagged . Bookmark the permalink.

Leave a Reply