将 ASMX 转换为 WCF Web 服务 [英] Converting ASMX to WCF Web Service

查看:34
本文介绍了将 ASMX 转换为 WCF Web 服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要升级我们的 Web 服务以使用 WCF 而不是 ASMX.如果 Web 服务的签名保持不变,那么已经调用 ASMX 服务的现有客户端是否需要更改任何内容?无论如何仍然使用WCF但不强迫他们改变任何东西?

I need to upgrade our web services to use WCF instead of ASMX. If the signatures of the web services stays the same, will existing clients that already call the ASMX service have to change anything on their end? Is there anyway to still use WCF but not force them to change anything?

推荐答案

Option 1 :

  1. 使用当前 ASMX 的 WSDL,使用 svcutil.exe 生成客户端

  1. Using the current ASMX's WSDL, generate the client using svcutil.exe

抓取生成的接口并基于该接口创建WCF服务

Grab the generated interface and create a WCF service based on this interface

输出:一个新的 WCF 端点配置了 basicHttpBinding.客户端需要更新他们发送消息的 URL.

Output : One new WCF endpoint configured with basicHttpBinding. Clients need to update the URL at which they're sending the messages.

选项 2:

  1. 重构您的 ASMX 代码.将所有逻辑移动到一个单独的 DLL 中.

  1. Refactor your ASMX code. Move all the logic into a separate DLL.

创建 WCF 服务并使用重构后的 DLL 中的逻辑.

Create a WCF service and use the logic in the refactored DLL.

输出:2 个端点,一个用于 ASMX,另一个用于 WCF

Output : 2 endpoints, one for ASMX and another one for WCF

这篇关于将 ASMX 转换为 WCF Web 服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆