Alex Rivera | Logout

DataContract vs Message Contract

Asked 2010-11-07T16:50:29.810
38

Though I have read some WCF articles about message contract, but I am not able to comprehend what is the real use of message contract. Can I use MessageContract instead of DataContract or in complement to DataContract?

Edit
Report

2 Answers

17

A DataContract is a description of a type that is exposed and supported by your service. A MessageContract is an abstraction over a SOAP message that allows you to explicitly dictate the structure of the underlying message.

They are meant to compliment each other and serve different purposes.

answered 2010-11-07T16:57:57.303
9

Marc Gravell answered to a similar question WCF: MessageContract, DataContract ... Confused?

One of the advantages of message-contracts is that you can set privacy against members, but in many cases this isn't necessary. In such cases, I prefer to keep the contract as simple as possible, just as a data-contract.

answered 2012-05-04T03:20:23.613

Your Answer