在 Silverlight 中使用 WCF 时添加服务引用有什么问题?

发布于 2024-07-23 01:59:51 字数 291 浏览 4 评论 0原文

本文讨论如何使用 WCF 服务Silverlight,但声称:

不会有代理,不会生成代码,不会有第 3 方实用程序,也不会令人厌恶的“添加服务引用”用法。

我在 Silverlight 中添加服务引用有什么问题项目? 是否有隐藏的管理费用? 还是作者对自动魔法的恐惧?

This article talks about consuming WCF services in Silverlight, but claims:

There will be no proxies, no generated code, no 3rd party utilities, and no disgusting "Add Service Reference" usage.

What is so wrong with me adding a service reference in my Silverlight project? Are there hidden overheads? Or is it a case of Fear Of Auto Magic on the part of the author?

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

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

发布评论

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

评论(2

蓝梦月影 2024-07-30 01:59:51

作者发表这一言论的理由似乎是:

首先,我要提醒大家,切勿在 Visual Studio 中使用“添加服务引用”来创建神奇的服务客户端。 代码非常冗长,难以管理,编辑很容易被覆盖,而且它几乎总是被用作不真正学习 WCF 的借口。 没有什么比不得不与那些自以为了解产品只是因为他们知道如何使用鼠标的人打交道更糟糕的了。

作为专门依赖 Silverlight 中“添加服务引用”的人,我认为这有点过头了。 我同意自动生成的代码很冗长,不应该对其进行编辑,因为它会被覆盖。 然而,就可管理性而言,它并没有变得更简单,为了响应我的服务更改,只需单击一下即可使服务引用恢复同步。

尽管如此,我认为这篇文章非常好,而且我可以保证添加服务引用的简便性阻止了我深入研究 WCF。 这不一定是坏事,因为归根结底,WCF 是管道系统,我有兴趣编写我的应用程序,而不是成为 WCF 专家。 碰巧我现在遇到了 Silverlight 和我的服务之间的一些序列化问题,我怀疑这些问题与浏览器有关。 我需要更深入地研究 WCF 来解决这个问题,那篇文章看起来是一个完美的起点。

“添加服务引用”对我来说已经很好了 1.5 年,当然,了解 WCF 的内部结构有好处,但通过快速简单的点击方式从 Visual Studio 中开始使用绝对没有问题。 。

The reasoning for that statement from the author appears to be:

To begin, let me start off by reminding everyone that you shouldn't ever use "Add Service Reference" in Visual Studio for magical service client creation. The code is incredibly verbose, hard to manageable, edits are prone to being overwritten, and it's almost always used as an excuse to not actually learn WCF. There are few things worse than having to deal with people who thing they know a product simply because they know how to use a mouse.

As someone who has relied on the "Add Service Reference" in Silverlight exclusively I think that is a bit over the top. I'd agree that the auto-generated code is verbose and it shouldn't be edited because it WILL be overwritten. However as far as manageability goes it doesn't get any simpler, in response to my service changing it takes one click to get the service reference back in sync.

Despite that I think the article is very good and I can vouch that the ease of adding service references has stopped me from delving deeply into WCF. That's not necessarily a bad thing as at the end of the day WCF is plumbing and I'm interested in writing my app not becoming a WCF expert. As it happens I have now reached a point where I am encountering some serialisation issues between Silverlight and my service which I suspect are related to the browser. I'll need to dig deeper into WCF to sort it out and that article looks like th perfect starting point.

The "Add Service Reference" has been fine for me for 1.5 years and while of course there are benefits to learning about the internals of WCF there is definitely nothing wrong with having a quick and simple point and click way to get started from within Visual Studio.

阳光下慵懒的猫 2024-07-30 01:59:51

Silverlight 中的“添加服务引用”现在存在一些问题...每次更新服务时都会重新生成配置文件。

它比人们强调的“汽车魔法”问题更进一步。 首先,通过服务引用,您可以“耦合”到服务及其公开的方法。 如果您重新生成服务,客户端也必须执行相同的操作。 动态创建服务可以缓解这个问题。 此外,通过抽象/反射/依赖注入,您现在拥有解耦的服务引用。

我不认为服务引用不好,但是 WCF 和 Web 概念正在远离它。 例如,WCF REST 标准没有您使用的“服务引用”...它只是 URL 路由表。 越来越多的人推荐将此作为标准,例如 Juwal Lowy(idesign.net 和几本 WCF 书籍的作者)建议不要使用服务引用。

"Adding a service reference" in Silverlight has some problems right now...the config file gets regenerated each time the service is updated.

It goes a little further than the "auto magic" people are stressing as a problem. First, with a service reference you are "coupled" to the service and it's methods it exposes. If you re-generate the service the client has to do the same. Creating the service dynamically alleviates that problem. Furthermore, with abstraction/reflection/Dependency Injection you now have decoupled service references.

I don't think service references are bad, however WCF and web concepts are moving away from it. For example, WCF REST standards have no "service reference" that you consume...its just URL routing tables. More and more people are recommending this as a standard, for example Juwal Lowy (idesign.net and author of a couple WCF books) recommends not using service references as well.

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