简体   繁体   English

使用WCF数据服务

[英]Using a WCF Data Service

I built a WCF Data Service by following a blog. 我通过关注博客构建了WCF数据服务。

It works ok, but I don't get the expected result format in the browser. 可以,但是在浏览器中没有得到预期的结果格式。

When I run the project, I get this: 当我运行项目时,我得到以下信息:

在此处输入图片说明

But, when I try to browse one of these tables, say Customers, this is what I get: 但是,当我尝试浏览这些表之一时,说客户,这就是我得到的:

在此处输入图片说明

As you can see, the Customers are there, but all I see is the current date for each one of them. 如您所见,客户在那里,但是我所看到的只是每个客户的当前日期。

There must be something I'm not doing. 一定有我没做的事。

It looks to me like firefox is displaying the data as an RSS Feed because your service returns an xml payload. 在我看来,firefox将数据显示为RSS Feed,因为您的服务返回了xml有效负载。 There should be a setting in Firefox to turn it off... I think it is under firefox > options > applications > web feed. Firefox中应该有一个设置将其关闭...我认为它位于firefox>选项>应用程序> Web feed下。

Since the response is ATOM-based, Firefox will assume this is an RSS feed and try to apply the RSS view (and fail, as you can see). 由于响应是基于ATOM的,因此Firefox将假定这是RSS源,并尝试应用RSS视图(如您所见,会失败)。

I tend to use IE when working with OData (and disable "Feed Reading view" under Options -> Content). 使用OData时,我倾向于使用IE(并在“选项”->“内容”下禁用“进纸阅读视图”)。 In Firefox you can change some settings under Options -> Applications -> Web Feed, but I haven't figured out yet how to completely disable it. 在Firefox中,您可以在“选项”->“应用程序”->“ Web Feed”下更改某些设置,但是我还没有弄清楚如何完全禁用它。

As other answers have said, this is the default RSS view, correctly rendered in Firefox. 就像其他答案所说的那样,这是默认的RSS视图,可以在Firefox中正确呈现。 You can still use the View Page Source option in Firefox to view the actual XML returned by your server. 您仍然可以在Firefox中使用“查看页面源”选项来查看服务器返回的实际XML。

If you want your data to render in a more user-friendly manner in the default RSS view you will have to use OData's feed customisation features, for example, to set a value for the Atom title field. 如果希望在默认的RSS视图中以更加用户友好的方式呈现数据,则必须使用OData的feed自定义功能,例如,为Atom标题字段设置一个值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM