none
Data Contracts vs Message Contracts RRS feed

  • Question

  • Hello,

    I'm not sure when I should use a message contract.  In fact why would I use a message?  After all my operation parameters get serialized into a soap envelope automatically.

    So when would I use a message and when would I use a serilizable class?

    Thanks in advance

    Houman

    Wednesday, October 18, 2006 3:05 PM

Answers

  • A data contract describes the data that your service operations exchange. Data contracts describe only the data transferred from one side to the other; generally they do not describe the message that carries the data.A message contract would hold all the required information about the message payload itself ie: <SOAP:BODY> itself.

    Use Message Contracts to implement SOAP Headers, etc.

     

    Wednesday, October 18, 2006 4:12 PM
  •  

    Message Contract allows finer control to specify how data gets serialized in SOAP body or SOAP header.

    Why use Message Contract?

    1. Interoperability. For example: If you need to add custom SOAP headers needed to interop with other existing systems.

    2. Not wanting to use DataContract versioning and to keep a open Message type across service operations.

    3. You want to complicate others work :-)

    I would rather use DataContracts except for #1.

    T.Ramesh.

    Wednesday, October 18, 2006 4:57 PM

All replies

  • A data contract describes the data that your service operations exchange. Data contracts describe only the data transferred from one side to the other; generally they do not describe the message that carries the data.A message contract would hold all the required information about the message payload itself ie: <SOAP:BODY> itself.

    Use Message Contracts to implement SOAP Headers, etc.

     

    Wednesday, October 18, 2006 4:12 PM
  • Thank you.  I'm new this type of architecture and design, so the question is when/why would I want to write my own messages when I get them for free with WCF bindings?

    Thanks

    Houman

    Wednesday, October 18, 2006 4:24 PM
  •  

    Message Contract allows finer control to specify how data gets serialized in SOAP body or SOAP header.

    Why use Message Contract?

    1. Interoperability. For example: If you need to add custom SOAP headers needed to interop with other existing systems.

    2. Not wanting to use DataContract versioning and to keep a open Message type across service operations.

    3. You want to complicate others work :-)

    I would rather use DataContracts except for #1.

    T.Ramesh.

    Wednesday, October 18, 2006 4:57 PM
  • Thanks!
    Friday, October 20, 2006 6:59 PM
  • Hi ramesh. I agree with your point. But is there any live scenerio where in we cannot do without message contract.

     


    chandan mahajan
    Monday, November 29, 2010 12:16 PM