Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When should I use Message Contracts instead of DataContract and why?

Tags:

wcf

Can anyone please tell me when should I use MessageContracts and when should I use DataContracts and why ? As I write my wcf service , I always use DataContract but don't know the use of MessageContracts . Please someone elaborate..

like image 540
Embedd_0913 Avatar asked Jul 06 '09 07:07

Embedd_0913


People also ask

What is a message contract?

A message contract is used to control the structure of a message body and serialization process. It is used to send/access the information in the soap header. By use of a Message Contract we can customize the parameters sent using a SOAP message between the client and the server.

Why Datacontract is used in WCF?

A data contract is a formal agreement between a service and a client that abstractly describes the data to be exchanged. That is, to communicate, the client and the service do not have to share the same types, only the same data contracts.


1 Answers

Use Message Contracts when you need more control. In particular, to specify Headers.

like image 54
John Saunders Avatar answered Oct 02 '22 03:10

John Saunders