Wednesday, February 11, 2009

WCF 3.5 Message Contracts

From practical usage stand point, I've rarely used WCF Message Contracts. My work a lot of time revolved around Data Contracts and Service Contracts. I feel using Message Contracts are limited in their usage except for passing around few custom headers. But, they might be of great help for other folks around. so, let's see what is a message contract?

Defining message contracts lets you gain control over entire SOAP message and NOT just over the structure of data in the body as case with data contracts. Message Contracts deal with accessing and supplying custom headers and lets you define your own message structure.

There's no partial usage of message contracts. After you introduce a message contract into an operation signature, you must use a message contract as the only parameter type and as return type of the operation instead of any data contract for parameters or return type.