Using MessageContract to control the SOAP message

DataContract can help us design the data types used in a WCF service. However, this only covers the data members (variables and parameters used in operation) serialized in the underlying SOAP message. Sometimes we also need to control the structure and format of the entire SOAP message.

WCF introduces a MessageContract concept, which helps service developers to model the structure and format of the entire message of a given service operation. Actually, we can take MessageContract type as a special DataContract type, which is marked by the MessageContractAttribute. This recipe will show you how we can define a typical MessageContract for our WCF service operation to control the format of the underlying ...

Get Microsoft Windows Communication Foundation 4.0 Cookbook for Developing SOA Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.