WCF 数据服务:为什么每个数据上下文都需要 URI,这在典型的分层架构中适合什么位置?
我正在考虑在我的一个项目中实施 WCF 数据服务。经过广泛的研究,我有一些尚未解答的问题。如果有人可以帮助我吗?
当我们传递具体数据特定操作时(尽管使用 URI 通过 HTTP),为什么在大多数文档中 WCF 数据服务位于 UI 层旁边?难道它不应该是比 UI 和 EDM 之间的接口更高的抽象级别吗?
为什么需要传递 URI 来建立上下文? URI 不是传递到 ADD SERVICE REFERENCE(或 DATASVCUTIL)中以生成客户端代理类吗?为什么每当需要建立上下文时都会出现这种冗余?
如果我的服务 URL 发生变化怎么办?如何动态确定该服务的URL?例如,假设我有一个 WCF 数据服务 http://localhost:8443/project1/WCFSERVICE1 。我如何在运行时动态获取此 URL(因为 VS 下的端口发生变化)???
我见过一些使用DataServiceRequest和DataServiceResponse的例子;有时它们不是,而是通过 CREATEQUERY 或 EXECUTE 直接执行查询。一行有什么区别?
如何通过公司网络代理访问远程服务?我知道我们可以将默认凭据传递给 Web 请求,但是如何使用 WCF 数据服务客户端代理类来完成此操作?
PS 目前,我已经在 Visual Studio 中配置了静态端口。但是,如何动态获取这个端口呢? 感谢您的帮助。
I am considering implementing WCF Data services in one of my projects. After extensive research, I have some questions that have yet to be answered. If someone can please help me out?
When we are passing concrete data specific operations (albeit over HTTP using URI's), why is a WCF data service next to the UI layer in most of the documentations? Shouldn't it be a higher level of abstraction than interfacing between UI and the EDM?
Why is the passing of a URI needed to establish context? Wasn't the URI passed into the ADD SERVICE REFERENCE (or DATASVCUTIL) to generate client proxy classes? Why this redundancy whenever a context needs to be established?
What if my service URL changes? How to determine this service URL dynamically? For example, let's assume I have a WCF DATA SERVICE at http://localhost:8443/project1/WCFSERVICE1. How can i get this URL dynamically at runtime (because of the changing port under VS)????
I have seen some examples where DataServiceRequest and DataServiceResponse are used; sometimes they are not and the query is directly executed via CREATEQUERY or EXECUTE. What is the difference in one line??
How to access a remote service over corporate network proxy? I know we can pass defaultcredentials to the webrequest but how is that to be done with wcf data service client proxy classes?
P.S. For now, I have configured a static port in visual studio. However, how to get this port dynamically?
Appreciate your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
刚刚看到这个,我相信现在您已经找到了大部分问题的答案,但这里是。
你的问题3就是你标题问题的答案。在构造函数中传递 URI 意味着数据服务的位置具有更大的运行时灵活性。因此,就我而言,我将端口和服务器名称作为应用程序设置,可以在运行时进行修改,而无需修改应用程序。
希望这有帮助。
Just saw this, I'm sure by now you've got answers to most of these questions, but here goes.
Your question 3 is the answer to your title question. Passing the URI in the constructor means you have greater runtime flexibility for the location of the data service. So in my case I've got the port and server name as application settings that can be modified at runtime without the need to modify the application.
Hope this helps.