如何从 ADO.NET 数据服务返回纯 XML
我想知道如何从 ADO.net 数据服务返回纯 XML
我已经向我们公司的不同技术部门公开了 ADO.net 数据服务。返回的数据是ATOM FEED
,其格式有点难以阅读/解释,并且返回了太多信息。
来自不同部门的人员会执行不同的查询(HTTP 请求),我希望他们显示简单的 XML 或至少显示一些对用户更友好的内容,例如 HTML
我已尝试将请求的 ACCEPT
属性设置为简单的 XML
并且它仍然返回 ATOM
I was wondering how to return plain XML from ADO.net data services
I have exposed an ADO.net data service to different departments in our company who are not so technical. The data returned is ATOM FEED
which is some-what hard to read / interpret with its format and too much information is returned.
People from various departments would execute different queries ( HTTP Request) and I would like them to display simple XML or at least something more user friendly like HTML
I have tried ACCEPT
attribute of the request to be plain XML
and it still returns ATOM
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果我是你,我会使用友好提要,这是 WCF 数据服务的一项功能,它允许您将属性映射到提要字段,这些字段将在任何 rss 提要阅读器上显示为正确的 rss 提要,甚至是 IE 7 和 8 中的默认提要阅读器会显示它们并为您排序。
WCF 数据服务源自定义< /a>
希望这有帮助
If I were you I would use Friendly feeds which is a feature of WCF Data Services, which allows you to map properties to feed fields which would show as proper rss feeds on any rss feed reader, even the default feed reader from IE 7 and 8 would display them and sort them for you.
WCF Data Services Feed Customization
hope this helps
ADO.NET 数据服务 - 现在称为 WCF 数据服务 - 将始终返回 Atom feed - 这是它们功能的核心。
然而,在解释和使用该 Atom feed 时,您应该不会遇到任何麻烦。在客户端,您只需对服务 URL 执行
添加服务引用
,就会生成一个漂亮、干净的客户端代理,并包含可用于读取的 .NET 对象类并解释 WCF 数据服务的输出。您甚至可以针对此客户端类使用 LINQ 来执行查询!我建议您了解并使用 Atom,而不是试图对抗它。
ADO.NET Data Services - now known as WCF Data Services - will always return an Atom feed - that's the core of their functioning.
You shouldn't have any trouble, however, interpreting and working with that Atom feed. On the client side, you can just do a
Add Service Reference
to the service URL, and a nice, clean client-side proxy will be generated, complete with .NET object classes which you can use to read and interpret the output from the WCF Data Service. You can even use LINQ against this client classes to do your queries!I would recommend you get to know and use Atom, instead of trying to fight it.