ASMX 与 WCF

发布于 2024-07-30 14:45:02 字数 424 浏览 3 评论 0原文

我需要一些与这个主题相关的指导; 也许我错过了显而易见的事情。

我没有看到绑定到 HTTP 的 WCF 和强类型 Web 服务之间的对比。 为什么这会有所不同? 我同意 ASMX 与 WCF 中存在一些与 XmlSerializer 特别相关的开发细微差别以及大量的 Microsoft 术语。 缺少这些; 我只看到并行

DataContract=WSDL 类型 ServiceContract=WSDL(又名服务定义) OperationContract=WebMethod

在操作上,我知道使用 WCF 可以进行大量绑定,而不是锁定到 HTTP,这可能涉及繁重的构建和拆卸。 但对于松散耦合来说,这一切都将是 Web 服务。

还有其他操作上的区别吗?

有人可以向我展示光明并让我摆脱痛苦吗? :))

I need some direction related to this topic; maybe I am missing the obvious.

I dont see a contrast between WCF bound to HTTP and strongly typed web service. Why would this be any different?? I agree there are some development nuances especially related to XmlSerializer in ASMX vs WCF and a plethora of Microsoft jargons. Short of these; i only see parallels

DataContract=WSDL Type
ServiceContract=WSDL (aka service definition)
OperationContract=WebMethod

Operationally, I understand the binding can be numerous with WCF instead of getting locked down to HTTP, which can involve heavy construct and tear down. But for loose coupling it will all be web services.

Are there other operational differences??

Can someone show me the light and put me out of my misery?? :))

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

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

发布评论

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

评论(3

如果没有 2024-08-06 14:45:03

好吧,如果您将讨论减少到仅 HTTP,那么 WCF 相对于 ASMX 仍然具有许多优势:

  • 更多更好的安全设置(使用传输或消息安全的能力)
  • 更多的灵活性 - 可以配置和使用更多内容在WCF中进行了调整,无论是在配置文件中还是在代码中
  • ASMX Web服务只能存在于IIS内部——IIS是必须具备的要求; 您可以在控制台应用程序或 Windows NT 服务中自行托管 WCF 服务。
  • 在 WCF 中使用服务和数据契约的明确重点使得界面更加简洁,并且更好地分离关注点(最终是更好的代码)
  • 支持诸如可靠的消息传递和事务支持(甚至通过 HTTP)之类的东西

简而言之:即使当您将 WCF 限制为仅 HTTP 时差异可能会更小,但我仍然认为它是优越的,如果您今天可以选择开始新的东西,无论如何,使用WCF代替ASMX!

Rick Strahl 在他的博客文章中说得非常好:

我认为,即使您坚持使用纯 HTTP 和 SOAP,对任何新服务使用 WCF 也可能是一个好主意,因为通过使用 WCF 创建服务,您可以稍后决定使用 WAS 发布相同的服务,并提供更高的性能TCP/IP 传输。 或者,您可能会被要求提供 WS 协议的一些高级功能,例如事务、附件、会话管理、加密等。通过使用 WCF,您正在构建着眼于未来的服务,以便您可以轻松迁移直到其他协议——其中一些协议今天可能还不存在。 当然,未来将会出现新技术,WCF 通过其抽象层和通用 API 在一定程度上保护您。*

Marc

Well, if you reduce your discussion to only HTTP, then there's still a slew of advantages that WCF has over ASMX:

  • more and better security settings (ability to use either transport or message security)
  • much more flexibility - a lot more can be configured and tweaked in WCF, either in configuration files or code
  • ASMX web services can only exist inside IIS - IIS is a must-have requirement; you can self-host your WCF services in a console app or Windows NT Service
  • the clear focus on using Service and Data Contracts in WCF makes for a much cleaner interface and a much better separation of concern (better code, in the end)
  • support for things like reliable messaging and transaction support (even over HTTP)

In short: even though the differences might be smaller when you restrain WCF to just HTTP, I still think it's superior and if you have the choice to start something new today, by all means, use WCF instead of ASMX!

Rick Strahl puts it very nicely in his blog post:

I would argue that using WCF for any new services is probably a good idea even if you stick with pure HTTP and SOAP because by creating your service with WCF you can decide later on to publish this same service using WAS and also provide the more high performance TCP/IP transport. Or you might be asked to provide some of the advanced features of WS- protocols like transactions, attachments, session management, encryption etc. By using WCF you are building your service with a view to the future so you can easily move up to other protocols-some of which may not even exist today. Certainly new technologies will come along in the future and WCF protects you somewhat through its abstraction layer and common API.*

Marc

阳光下的泡沫是彩色的 2024-08-06 14:45:03

对于 ASMX Web 服务的使用者来说,还有一点是,任何使用该 Web 服务的平台都必须实现 SOAP 堆栈。 如果您的目标是广泛使用,那么 WCF 更可取,它允许您以更通用的方式公开 WS。

Another point for the consumers of the ASMX web service, which ever platforms will consume the web service will have to implement a SOAP stack. If you're goal is for wide reaching consumption, WCF is preferable and will allow you to expose the WS in more universal ways.

满地尘埃落定 2024-08-06 14:45:03

这两种技术之间的另一个重大区别是,Microsoft 现在将 ASMX Web 服务和 XML Serializer 视为“遗留技术”,并且不再修复其中的错误。

The other big distinction between the two technologies is that Microsoft now considers both ASMX web services and XML Serializer to be "legacy technology", and is no longer fixing bugs in them.

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