[英]What is the purpose of the IsWrapped property in WCF
What is the purpose of the "IsWrapped" property in WCF. WCF中“ IsWrapped”属性的用途是什么。 In which situation should I use this property and why? 在哪种情况下我应该使用此属性,为什么?
Unwrapped Messages (MSDN) : 未包装的邮件(MSDN) :
By default, the message body is formatted such that the parameters to a service operation are wrapped. 默认情况下,邮件正文的格式设置为,用于包装服务操作的参数。
And 和
MessageContractAttribute.IsWrapped Property (MSDN) : MessageContractAttribute.IsWrapped属性(MSDN) :
Set the value of IsWrapped to false to suppress the wrapper element into which the message body is serialized. 将IsWrapped的值设置为false可以禁止将消息正文序列化到的wrapper元素。
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): 当您将IsWrapped
设置为false
,消息正文将不会被包装在具有动作名称的元素中(在这种情况下为Add
):
<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. 诸如此类的属性旨在实现互操作性,例如,在编写客户端以使用不希望消息被包装的服务时。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.