Can I use MessageContract instead of DataContract or in complement to DataContract?

Technology CommunityCategory: WCFCan I use MessageContract instead of DataContract or in complement to DataContract?
VietMX Staff asked 3 years ago
  • 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 purpose:

  • Using DataContract, the service can expose the types that it interchanges. But the XML (SOAP) that is interchanged is not controlled (though impacted) by it.
  • While MessageContract can be used to explicitly define how the XML (SOAP message) will be structured.