How do I configure WCF client to use XElement and not XmlDocument?

给你一囗甜甜゛ 提交于 2019-12-24 15:13:58

问题


I have an ASMX webservice that returns XElement - (not an .svc WCF service)

When consuming the service in Silverlight the client that is generated uses XElement as I want.

However in C# .NET 3.5 WCF 'Service Reference' it generates this property using XmlDocument.

In C# .NET 4 WCF 'Service Reference' it also generates this property using XmlDocument. So it doesn't seem to be a .NET 4 thing - but a Silverlight thing.

How can I configure the WCF client to use XElement also in the standard 3.5 framework?


回答1:


I Find/Replace XMLElement with XElement in my proxy class. Dirty trick... but it works.




回答2:


I switched the service from an ASMX web service to SVC WCF service. Wasn't much work at all. Just one more thing I never got round to doing.

This then without changing anything else allowed the .NET 3.5 client to use XElement instead of XmlElement.

Looks like Silverlight is just smart enough to always use XElement - come to think of it XmlDocument probably doesn't even exist in the Silverlight framework in the first place.



来源:https://stackoverflow.com/questions/1904477/how-do-i-configure-wcf-client-to-use-xelement-and-not-xmldocument

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!