在WCF响应中省略NULL值 [英] Omit NULL values in WCF response

查看:94
本文介绍了在WCF响应中省略NULL值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


在我的WCF服务中,我定义了一个

Hi
In my WCF Service I defined

        [DataMember(IsRequired = false)]
        public string Test { get; set; }


。当我没有设置Test属性时,WCF将生成 < d4p1:测试i:nil < span style ="font-size:xx-small; color:#0000ff"> =" true ">< / d4p1:Test >
如何省略元素,即null?
谢谢


wima

in a response type. When I do not set the Test property, WCF will generate <d4p1:Test i:nil="true"></d4p1:Test>
How can I omit elements, that ar null?
Thank you


wima

推荐答案

我也想回答这个问题。我在网上发现了一些关于XML序列化的内容,它使用了一个特殊的方法,其名称是前缀为"ShouldSerialize"的属性名称,但它似乎对WCF没有任何影响。
I would like an answer to this one too. I found something on-line about XML serialization utilitizing a special method whose name is the property name prefixed with "ShouldSerialize", but it doesn't seem to have any effect for WCF.


这篇关于在WCF响应中省略NULL值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆