WCF 中 IsWrapped 属性的用途是什么 [英] What is the purpose of the IsWrapped property in WCF
问题描述
WCF 中IsWrapped"属性的用途是什么.我应该在什么情况下使用这个属性,为什么?
What is the purpose of the "IsWrapped" property in WCF. In which situation should I use this property and why?
推荐答案
默认情况下,消息正文的格式设置为包装服务操作的参数.
By default, the message body is formatted such that the parameters to a service operation are wrapped.
和
MessageContractAttribute.IsWrapped 属性 (MSDN):
将 IsWrapped 的值设置为 false 以抑制消息正文序列化到的包装元素.
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>
当您将 IsWrapped
设置为 false
时,消息正文将不会包含在具有操作名称的元素中(在此为 Add
案例):
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.
这篇关于WCF 中 IsWrapped 属性的用途是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!