简体   繁体   English

将ASMX转换为WCF Web服务

[英]Converting ASMX to WCF Web Service

I need to upgrade our web services to use WCF instead of ASMX. 我需要升级我们的Web服务以使用WCF而不是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? 如果Web服务的签名保持不变,那么已经调用ASMX服务的现有客户端是否必须更改任何内容? Is there anyway to still use WCF but not force them to change anything? 无论如何仍然使用WCF但不强迫他们改变任何东西?

Option 1 : 选项1 :

  1. Using the current ASMX's WSDL, generate the client using svcutil.exe 使用当前的ASMX的WSDL,使用svcutil.exe生成客户端
  2. Grab the generated interface and create a WCF service based on this interface 获取生成的接口并基于此接口创建WCF服务

    Output : One new WCF endpoint configured with basicHttpBinding. 输出:使用basicHttpBinding配置的一个新WCF端点。 Clients need to update the URL at which they're sending the messages. 客户端需要更新他们发送消息的URL。

Option 2 : 选项2:

  1. Refactor your ASMX code. 重构您的ASMX代码。 Move all the logic into a separate DLL. 将所有逻辑移动到单独的DLL中。
  2. Create a WCF service and use the logic in the refactored DLL. 创建WCF服务并使用重构DLL中的逻辑。

    Output : 2 endpoints, one for ASMX and another one for WCF 输出:2个端点,一个用于ASMX,另一个用于WCF

If you use the BasicHttpBinding for your new WCF service, and implement the same methods with the same message structure, existing callers should be able to call into this new WCF service without any change on their part. 如果您将BasicHttpBinding用于新的WCF服务,并使用相同的消息结构实现相同的方法,则现有的调用者应该能够调用这个新的WCF服务而不需要对其进行任何更改。

There's also an AspNetCompatibilityRequirements attribute in order to get around some potential compatibility issue - see the MSDN documentation on it. 还有一个AspNetCompatibilityRequirements属性,以解决一些潜在的兼容性问题 - 请参阅相关的MSDN文档

Marc

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

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