none
Message contracts and data contracts RRS feed

  • Question

  • I need to develope a WCF Service and i have large amount of value objects to be define initialy i thought of defining all value (entity) objects as data contracts but if i define those as message contracts will their be any advantagoues.

    Thanks.
    Rohan Fernando
    Friday, September 11, 2009 10:06 AM

Answers

  • Hi,

    Typically when building Windows Communication Foundation (WCF) applications, developers pay close attention to the data structures and serialization issues and do not need to concern themselves with the messages in which the data is carried. For these applications, creating data contracts for the parameters or return values is straightforward. (For more information, see Specifying Data Transfer in Service Contracts.)

    However, sometimes complete control over the structure of a SOAP message is just as important as control over its contents. This is especially true when interoperability is important or to specifically control security issues at the level of the message or message part. In these cases, you can create a message contract that enables you to use a type for a parameter or return value that serializes directly into the precise SOAP message that you need.

    Reference link:http://msdn.microsoft.com/en-us/library/ms730255.aspx

    Thanks
    Binze


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Proposed as answer by Will.Rogers Wednesday, September 16, 2009 11:38 AM
    • Marked as answer by Bin-ze Zhao Friday, September 18, 2009 2:38 AM
    Wednesday, September 16, 2009 10:22 AM
  • The idea behind MessageContracts is that it gives you greater control. The body is commonly defined using a DataContract but you can also specify your own SOAP headers as well (with either simple types or more DataContracts)

    I use a MessageContract is the WCF streaming screencast I made to stream the SOAP body but to buffer headers to allow the consumer to understand how to process the stream (you can find the screencast here http://rocksolidknowledge.com/ScreenCasts.mvc)


    Richard Blewett, thinktecture - http://www.dotnetconsult.co.uk/weblog2
    Twitter: richardblewett
    • Proposed as answer by Will.Rogers Wednesday, September 16, 2009 11:38 AM
    • Marked as answer by Bin-ze Zhao Friday, September 18, 2009 2:38 AM
    Wednesday, September 16, 2009 10:57 AM
    Moderator

All replies

  • Message contracts allow you to define the structure of a SOAP message, is that important to you?

    Regards,
    Stipe-Ivan
    Friday, September 11, 2009 11:53 AM
  • What is the advantage over defining the soap structure.
    Rohan Fernando
    Monday, September 14, 2009 3:34 AM
  • Hi,

    Typically when building Windows Communication Foundation (WCF) applications, developers pay close attention to the data structures and serialization issues and do not need to concern themselves with the messages in which the data is carried. For these applications, creating data contracts for the parameters or return values is straightforward. (For more information, see Specifying Data Transfer in Service Contracts.)

    However, sometimes complete control over the structure of a SOAP message is just as important as control over its contents. This is especially true when interoperability is important or to specifically control security issues at the level of the message or message part. In these cases, you can create a message contract that enables you to use a type for a parameter or return value that serializes directly into the precise SOAP message that you need.

    Reference link:http://msdn.microsoft.com/en-us/library/ms730255.aspx

    Thanks
    Binze


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Proposed as answer by Will.Rogers Wednesday, September 16, 2009 11:38 AM
    • Marked as answer by Bin-ze Zhao Friday, September 18, 2009 2:38 AM
    Wednesday, September 16, 2009 10:22 AM
  • The idea behind MessageContracts is that it gives you greater control. The body is commonly defined using a DataContract but you can also specify your own SOAP headers as well (with either simple types or more DataContracts)

    I use a MessageContract is the WCF streaming screencast I made to stream the SOAP body but to buffer headers to allow the consumer to understand how to process the stream (you can find the screencast here http://rocksolidknowledge.com/ScreenCasts.mvc)


    Richard Blewett, thinktecture - http://www.dotnetconsult.co.uk/weblog2
    Twitter: richardblewett
    • Proposed as answer by Will.Rogers Wednesday, September 16, 2009 11:38 AM
    • Marked as answer by Bin-ze Zhao Friday, September 18, 2009 2:38 AM
    Wednesday, September 16, 2009 10:57 AM
    Moderator