WCF 数据服务与 OData MVVM

发布于 2024-12-05 01:39:31 字数 787 浏览 0 评论 0原文

我只有普通 WCF 服务和 WCF REST 服务的实践经验,但随着需求的变化,我需要考虑其他选项......

OData 和 WCF 数据服务之间有什么区别?

.Net 中的 WCF 数据服务 OData 不是吗(它可以配置为返回 Atom feed 或 JSON 等)?

如果我想做一些比 CRUD 更复杂的事情怎么办?

例如,当我发出 Http 请求并得到如下响应时。

req = (HttpWebRequest)WebRequest.CreateDefault(new Uri(FCookieLocation));
HttpWebResponse resp1 = (HttpWebResponse)req.GetResponse();
Stream stream = resp.GetResponseStream();

然后我想做一些类似

while (true)
{
    byte b = stream.ReadByte();
}

但是 REST 服务的事情,一旦您从编写的方法返回,就立即终止响应。有没有办法让流在服务器端保持活动状态,这样我就可以继续向其中写入数据,而客户端则继续从中读取数据?

我知道 ASP.Net Web 处理程序具有这样的功能,但就我而言,我可能需要编写自己的 Web 服务器来侦听套接字上的 Http 请求(因此连接保持打开状态)以实现此目的,并可能继续写入套接字?

抱歉,如果问题不清楚,我可以解释一下。

如何最好地使用 WCF 数据服务来适应 MVVM 模式?

I have only had practical experience with plain WCF services and WCF REST services but as needs changed I need to look at other options....

What is the difference between OData and WCF Data servcies?

Isn't WCF Data Services OData in .Net (It can be configured to return Atom feed or JSON etc)?

What if I wanted to do something more complicated than just CRUD?

For example when I make a Http request and get a response like below.

req = (HttpWebRequest)WebRequest.CreateDefault(new Uri(FCookieLocation));
HttpWebResponse resp1 = (HttpWebResponse)req.GetResponse();
Stream stream = resp.GetResponseStream();

I want to then do something like

while (true)
{
    byte b = stream.ReadByte();
}

But REST Services, as soon as you return from the method you wrote, terminate the response immediately. Is there a way to keep the stream alive at the server end so I can keep writing data to it and the client just keeps reading from it?

I know ASP.Net web handlers have something of such a feature, but in my case I may need to write my own webserver that listens on a socket for Http requests(so connection stays open) to achieve this and keep writing to the socket perhaps?

Sorry if the question isn't clear just the best way I could explain it.

How is it best to use WCF Data Services to fit with the MVVM pattern?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

寒冷纷飞旳雪 2024-12-12 01:39:31

回答您的一些问题:

  1. WCF 数据服务是一种用于向客户端交付数据的技术(框架?)。它使用开放数据协议 (OData) 以 RESTful 方式交付这些结果。因此,WCF 数据服务是服务器(可以这么说),OData 是消息传递架构/格式。

  2. WCF 数据服务不是 .NET 中的 OData。再次强调,OData 只是有效负载模式; WCF 数据服务是交付机制。

  3. 您可以使用 WCF 数据服务执行比基本 CRUD 更复杂的操作。看一下 WCF 数据服务中的服务操作 - 它们本质上让您可以通过提供专门的方法来完成特定的事情来增强您的服务。您还可以提供额外的 WCF 服务和操作来增强您的解决方案。

我不确定您关于流媒体和 MVVM 的其他问题...但我希望这至少是一个朝着正确方向的开始。

希望这有帮助!

To answer some of your questions:

  1. WCF Data Services is a technology (framework?) used to deliver data to clients. It uses the Open Data Protocol (OData) to deliver those results in a RESTful way. So WCF Data Services is the server (so to speak) and OData is the messaging schema/format.

  2. WCF Data Services is NOT OData in .NET. Again, OData is just the payload schema; WCF Data Services is the delivery mechanism.

  3. You can do something more complicated than just basic CRUD using WCF Data Services. Take a look at Service Operations in WCF Data Services -- they essentially let you enhance your service by providing specialized methods to do specific things. You can also provided additional WCF services and operations to enhance your solution.

I'm not sure about your other questions about streaming and MVVM...but I hope this at least is a start in the right direction.

Hope this helps!

寻找我们的幸福 2024-12-12 01:39:31

您的意思是通过 HTTP 持续流吗?

Do you mean a constant stream over HTTP?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文