Click here to Skip to main content
15,885,365 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.

How to return XMLDocument from WCF Contract.
Posted
Comments
Prakriti Goyal 23-Jul-14 8:49am    
Try using XElement instead of XmlDocument
http://stackoverflow.com/questions/964870/wcf-return-an-xmldocument
CPallini 23-Jul-14 9:08am    
Don't like the suggestion?

1 solution

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.
 
Share this answer
 
Comments
vishal_h 24-Jul-14 0:20am    
Thanks for reply.Is there any data Size limitation when converting XML into STring.
And if any ways i want to return XML from WCF then what will be the solution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900