如何将 WCF 客户端配置为使用 XElement 而不是 XmlDocument? [英] How do I configure WCF client to use XElement and not XmlDocument?
问题描述
我有一个 ASMX 网络服务,它返回 XElement
-(不是 .svc WCF 服务)
I have an ASMX webservice that returns XElement
- (not an .svc WCF service)
在 Silverlight 中使用服务时,生成的客户端根据需要使用 XElement
.
When consuming the service in Silverlight the client that is generated uses XElement
as I want.
但是在 C# .NET 3.5 WCF服务引用"中,它使用 XmlDocument
生成此属性.
However in C# .NET 3.5 WCF 'Service Reference' it generates this property using XmlDocument
.
在 C# .NET 4 WCF服务引用"中,它还使用 XmlDocument
生成此属性.所以它似乎不是 .NET 4 的东西 - 而是 Silverlight 的东西.
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.
如何配置 WCF 客户端以在标准 3.5 框架中也使用 XElement
?
How can I configure the WCF client to use XElement
also in the standard 3.5 framework?
推荐答案
我将服务从 ASMX
Web 服务切换到 SVC
WCF 服务.根本没有多少工作.还有一件事我从来没有做过.
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.
这在不更改任何其他内容的情况下允许 .NET 3.5 客户端使用 XElement
而不是 XmlElement
.
This then without changing anything else allowed the .NET 3.5 client to use XElement
instead of XmlElement
.
看起来 Silverlight 足够聪明,可以一直使用 XElement - 想想看,XmlDocument
可能一开始甚至不存在于 Silverlight 框架中.
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.
这篇关于如何将 WCF 客户端配置为使用 XElement 而不是 XmlDocument?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!