ServiceContractGenerator 与 ServiceDescriptionImporter

发布于 2024-08-11 05:02:39 字数 319 浏览 0 评论 0原文

我正在尝试构建一个轻量级 SOAP 客户端,而不使用“添加服务引用”。理想情况下,该客户端应该提供尽可能多的服务。目前,它使用ServiceDescriptionImporter来生成服务程序集。不幸的是,这似乎不适用于 WCF 服务。有人建议我改用 ServiceContractGenerator,因为 ServiceDescriptionImporter 是专门为 ASMX Web 服务设计的。

如果我使用 ServiceContractGenerator,我是否会被锁定为仅支持 WCF 服务?

I'm trying to build a light-weight SOAP client without using Add Service Reference. Ideally, this client should work for as many services as possible. Currently, it uses ServiceDescriptionImporter to generate the service assembly. Unfortunately, this doesn't appear to work for WCF services. Someone recommended that I use ServiceContractGenerator instead, because ServiceDescriptionImporter is designed specifically for ASMX web services.

If I use ServiceContractGenerator, will I be locked into only supporting WCF services?

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

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

发布评论

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

评论(1

仅此而已 2024-08-18 05:02:39

ServiceDescriptionImporter 是 VS 中的“添加 Web 引用”对话框和 SDK 中的“wsdl.exe”工具使用的类,用于生成“asmx”样式的客户端 Web 服务代理。 ServiceContractGenerator 相当于 WCF,用于 VS 中的“添加服务引用”对话框和 SDK 中的“svcutil.exe”工具。前者使用 asmx 客户端基础结构(System.Web.Services.Protocols.SoapHttpClientProtocol 等),后者使用 WCF 客户端基础结构(System.ServiceModel.ClientBase 等)。

两者都能够与大多数服务进行通信——也就是说,它旨在让 WCF 和 asmx 客户端基础设施能够与一系列 Web 服务标准广泛地互操作。 WCF 客户端可以与 asmx 服务器(以及其他供应商的服务器)通信,反之亦然。

也就是说,WCF 比 asmx 更新、更丰富、支持更好,并且支持更多的 WS 标准。您当然不会仅限于支持 WCF 服务。

ServiceDescriptionImporter is the class that is used by the "Add Web Reference" dialog in VS and the "wsdl.exe" tool in the SDK to generate "asmx"-style client web service proxies. ServiceContractGenerator is the WCF equivalent, for the "Add Service Reference" dialog in VS and the "svcutil.exe" tool in the SDK. The former uses the asmx client infrastructure (System.Web.Services.Protocols.SoapHttpClientProtocol and friends) and the latter uses the WCF client infrastructure (System.ServiceModel.ClientBase and friends).

Either will be able to talk to most services -- that is, it is intended for both the WCF and asmx client infrastructures to be broadly interoperable with a range of web services standards. A WCF client can talk to an asmx server (as well as servers from other vendors) and vice versa.

That said, WCF is newer, richer, better supported, and supports more WS standards than does asmx. You will certainly not be locked into only supporting WCF services.

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