Saturday, May 14, 2011

Message Contracts in WCF

Message Contracts

When developing your WCF services, Data contracts enable you to define the structure of the data that will be sent in the body of your SOAP messages, either in the inbound (request) messages or in the outbound (response) messages.

Message Contract Attributes are used to

A. control how the SOAP message body is structured and, ultimately, how it is serialized

B. Supply and access custom headers.

To define Message contracts, use the following attributes: MessageContract Attribute, MessageHeader Attribute, and MessageBodyMember Attribute.

The MessageContract Attribute: The MessageContract Attribute can be applied to classes and structures to define your own message structure.

The MessageHeader Attribute: The MessageHeader Attribute can be applied to members of a Message contract to declare which elements belong among the message headers.

The MessageBodyMemberAttribute: The MessageBodyMemberAttribute can be applied to members of your Message contracts to declare which elements belong within the message body.

No comments: