DATA CONTRACT SERIALIZER
Topics Mentioned in the article:
• What is Data Contract Serializer?
• What do you mean by Data Contract Resolver and how to use it?
• What is Data serialization and Data de-serialization?
• What do you mean by message contracts?
• What is meant by SOAP?
• What is Data contract?
• What is Data member?
• Difference between Data Contribute Attribute and Data Member Attribute
• How to create a contract type in Java?
What is Data Contract Serializer?
Before learning more about Data Contract Serializer, let us familiarize ourselves with the term WCF which stands for Windows Communication Foundation. The WCF (Windows Communication Foundation) infrastructure uses Data Contract Serializer as their default serializer to convert data into XML and to convert XML back into data. XML stands for Extensible Markup Language which is a markup language for storing, transmitting and reconstructing arbitrary data. The Data Contract Serializer is used to serialize and de-serialize data sent in Windows Communication Foundation (WCF) messages.
What do you mean by Data Contract Resolver and how to use it?
A data contract resolver allows you to configure known types in a dynamic manner. Known types are required when serializing or de-serializing a type which is not expected by a data contract.
After defining a data contract resolver, you can use it by passing it to the data contract sterilizer constructor.
What is data serialization and data de-serialization?
Data serialization is the process of converting a data structure or a data object into a series of bytes for storage, transfer, reconstruction and distribution purposes. It is useful for persistent data.
Data de-serialization on the other hand is the process of reconstructing a data structure or a data object from a series of bytes into data object in order to prepare it for usage. In simple words, it is the process of building a huge data object from a tiny stream of bytes.
What do you mean by message contracts?
Message contracts describe the structure of SOAP message that is passed between a service and a client. It has complete control over the SOAP message and is used to send or access information in or from the soap header.
What is meant by SOAP?
SOAP is an XML (Extensible Markup Language) based protocol used for accessing web services over http (Hypertext Transfer Protocol). In other words, it is a definition of how web services talk to each other or talk to clients.
What is Data contract?
A data contract is a formal agreement between a client and the service that clearly describes the data that is to be exchanged. To communicate, the client and the service do not have to share the same types but only the same contracts.
What is Data member?
Data members contain unique properties of an object. Data member of a class is any variable declared inside a class.
Difference between Data Contribute Attribute and Data Member Attribute
The Data Contract Attribute is applied to the class whereas Data Member Attribute is applied to members to instruct the Data Contract Serializer what is required to be serialized.
How to create a contract type in Java?
To create a type that conforms to the contract we have to first apply the Data Contract Attribute to the class. Then apply the Data Member Attribute to both private as well as public members.