So far we’ve looked into the ways of controlling the underlying service metadata on the client and the server. This time, we’ll inspect how to customize the message itself, with the help of message contracts.
As you could guess, there are a bunch of attributes which help us implementing this task. It’s good to know your enemy from the beginning, so here are them:
- MessageContractAttriubte: this attribute let’s you control the mappings between your custom types and their SOAP representations.
- MessageBodyMemberAttribute: the given field/property will be serialized as a member of the SOAP body.
- MessageHeaderAttribute: surprise! The given field/property will be serialized into a SOAP header.
- MessageHeaderArrayAttribute: defines that no wrapper element should be written to the specified array (each value in the array will be an independent element).
Well, only four attributes. That’s not a big deal for us, so let’s dive into the details!