如何在WCF中返回XmlDocument对象 [英] How to return XmlDocument object in WCF

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

问题描述

我想从WCF返回XmlDocument对象,但它给我错误

I want to return XmlDocument object from WCF but it giving me error as

Type 'System.Xml.XmlDocument' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute.



如何从WCF合同返回XMLDocument。


How to return XMLDocument from WCF Contract.

推荐答案

你必须使用别的东西。您始终只需返回一个字符串,调用者就可以加载到XDocument中。你甚至可以给你xDoc.ToString(),这样你就可以确定它是一个有效的XDocument。



我想你可能会发疯并写下你自己的所有课程但是这似乎有点矫枉过正。
You'll have to use something else. You can always just return a string and the caller can load into an XDocument. You could even return you xDoc.ToString() so you're sure it is a valid XDocument.

I suppose you could get crazy and write all your own classes but that seems way overkill.


这篇关于如何在WCF中返回XmlDocument对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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