What is the purpose of the IsWrapped property in WCF
c#, serialization, wcf, xml-serialization
Solution
Unwrapped Messages (MSDN):
By default, the message body is formatted such that the parameters to a service operation are wrapped.
And
MessageContractAttribute.IsWrapped Property (MSDN):
Set the value of IsWrapped to false to suppress the wrapper element into which the message body is serialized.
So, consider this (trimmed) message:
<s:Envelope>
<s:Body>
<Add>
<n1>100</n1>
<n2>15.99</n2>
</Add>
</s:Body>
</s:Envelope>
When you set `IsWrapped` to `false`, the message body won't be wrapped in an element with the action name (`Add` in this case):
<s:Envelope>
<s:Body>
<n1>100</n1>
<n2>15.99</n2>
</s:Body>
</s:Envelope>
Properties like these are meant for interoperability, for example when writing a client to consume a service which doesn't expect messages to be wrapped.
Problem
What is the purpose of the "IsWrapped" property in WCF. In which situation should I use this property and why?