简体   繁体   English

使用WCF服务暂时使用asmx Web服务

[英]Temporarily Facading asmx Web Service With WCF Service

I have an application that is an asmx web service written in .NET 2.0 with some business logic and a repository sitting underneath it. 我有一个应用程序是一个用.NET 2.0编写的asmx Web服务,它有一些业务逻辑和一个存储库。

The plan is that this web service will serve as the API for applications that want the data that it saves and retrieves. 计划是此Web服务将作为需要其保存和检索的数据的应用程序的API。

Longer term, I know that the web service is likely to be replaced by a WCF service when the .NET 2.0 code base is refactored and becomes a .NET 4 codebase. 从长远来看,我知道当.NET 2.0代码库被重构并成为.NET 4代码库时,Web服务可能会被W​​CF服务取代。

In order to reduce the impact on consumers of the API, I am considering whether it is a good idea to drop a WCF service as a facade over the asmx service. 为了减少对API消费者的影响,我正在考虑将WCF服务作为外观放在asmx服务上是否是一个好主意。 This will remain in place while the .NET 2.0 code is refactored. 在重构.NET 2.0代码时,这将保持不变。 When there is no .NET 2.0 code left, the asmx service will disappear and the WCF service will talk to the business logic without an asmx service in the way. 当没有剩余的.NET 2.0代码时,asmx服务将消失,并且WCF服务将在没有asmx服务的情况下与业务逻辑通信。

My questions are 我的问题是

What kind of performance overhead will this cause? 这会导致什么样的性能开销?

Is there a better solution to this problem? 这个问题有更好的解决方案吗?

You'll pay a double serialization / deserialization penalty for the additional service layer. 您将为附加服务层支付双序列化/反序列化惩罚。 If your messages are small, this won't be as noticeable. 如果您的消息很小,这将不会那么明显。

You might want to deploy a WCF version of the same service using BasicHttpBinding. 您可能希望使用BasicHttpBinding部署同一服务的WCF版本。 That way you get the best of both worlds: 这样你就可以获得两全其美:

  • The service is being deployed in one place using WCF (and is still available to legacy clients) 该服务使用WCF部署在一个地方(并且仍可供旧版客户端使用)
  • You can expose additional endpoints using different bindings if you want for the newer code. 如果需要更新的代码,可以使用不同的绑定公开其他端点。

EDIT: Of course, you could just hook up your new code to the old code using WCF based proxies. 编辑:当然,您可以使用基于WCF的代理将新代码连接到旧代码。 As long as you keep things named the same, your later refactor of the service shouldn't be too painful. 只要你保持命名相同的东西,你后来的服务重构就不应该太痛苦。

I read your question as “can I reference a .Net 2.0 component from a .Net 4 WCF service" 我将您的问题读作“我可以从.Net 4 WCF服务引用.Net 2.0组件”

This link confirms 此链接确认

The .NET Framework 4 is backward-compatible with applications that were built with the .NET Framework versions 1.1, 2.0, 3.0, and 3.5. .NET Framework 4向后兼容使用.NET Framework 1.1,2.0,3.0和3.5构建的应用程序。 In other words, applications and components built with previous versions of the .NET Framework will work on the .NET Framework 4. 换句话说,使用以前版本的.NET Framework构建的应用程序和组件将在.NET Framework 4上运行。

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

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