WCF 中 IsWrapped 属性的用途是什么

编程入门 行业动态 更新时间:2024-10-18 03:22:14
本文介绍了WCF 中 IsWrapped 属性的用途是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

WCF 中IsWrapped"属性的用途是什么.我应该在什么情况下使用这个属性,为什么?

What is the purpose of the "IsWrapped" property in WCF. In which situation should I use this property and why?

推荐答案

解包邮件 (MSDN):

默认情况下,消息正文的格式设置为包装服务操作的参数.

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 属性的用途是什么

本文发布于:2023-11-02 14:11:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1552620.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:属性   用途   WCF   IsWrapped

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!