从.Net 2.0标准ASMX Web服务客户端调用.Net 3.5 WCF服务

发布于 2024-07-16 07:36:52 字数 88 浏览 4 评论 0 原文

我创建了一个托管在安装了 .Net 3.5 的服务器上的服务,我需要从仅安装了 .Net 2.0 的客户端调用该服务。

我有办法做到这一点吗?

I created a service that is hosted on a server that has .Net 3.5 installed and I need to call this service from a client that only has .Net 2.0 installed.

Is there a way I can do this?

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

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

发布评论

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

评论(3

渡你暖光 2024-07-23 07:36:52

如果您的 WCF 服务使用 basicHttpBinding 公开端点,那么 .NET 2.0 客户端应该可以使用它。 正如马克所说,“没问题”。

If your WCF service exposes an endpoint using basicHttpBinding, then it should be possible for the .NET 2.0 client to consume it. As Marc said, "no problem".

妖妓 2024-07-23 07:36:52

是的,你可以做到。 然而,有一些警告:

您必须使用匹配的协议。 标准 .NET 2.0 库不支持许多安全 Web 服务功能; 事实上,如果您想使用 .NET 2.0 的默认安装,那么您几乎只能在 WCF 服务上使用 basicHttpBinding。 这在许多企业场景中是一个严重的限制。 然而,这可能就是您所需要的。

如果您需要更高的安全性但仍在使用 .NET 2.0,还有其他选择。 同样,您的 WCF 服务必须适应您的 .NET 2.0 客户端,但您的 .NET 2.0 客户端还需要利用外部库。 具体来说,您需要 Web 服务增强功能。 但请记住,这些库实现了某些 SOAP 协议的 beta 版本,而 WCF(在许多方面是 WSE 的后继者)默认实现这些标准。 由于协议(尤其是 WS-Addressing)发生了一些重大更改,因此您必须提供 customBinding 端点。

不幸的是,我无法告诉您将使用哪个,因为这取决于您想要在服务上容纳哪个协议,但是您的大多数问题将通过更改 textMessageEncoding 用于自定义绑定。 这不是最好的方案,但如果您尝试集成客户端,它可以为您带来一些好处。

底线是,要让 .NET 2.0 客户端与 WCF 服务进行除 basicHttpBinding 以外的任何操作,还需要做很多工作。 在许多情况下,basicHttpBinding 可能就足够了。 对于很多企业场景来说,却不会。 我不能说哪一个对你有帮助,但是有可能让它发挥作用——我已经成功地做到了。

但这是一个很大的痛苦。 如果可以的话,寻找替代方案。

Yes you can do it. There are some caveats, however:

You have to use protocols that match. The standard .NET 2.0 libraries don't support many secure web service features; in fact, you're pretty much stuck with using only basicHttpBinding on the WCF service if you want to be consumed by a default install of .NET 2.0. That is a severe limitation in many enterprise scenarios. However, it may be all you need.

If you need more security but are still using .NET 2.0, there are alternatives. Again, your WCF service must accommodate your .NET 2.0 client, but your .NET 2.0 client will also need to take advantage of an external library. Specifically, you'll need the Web Service Enhancements put out by Microsoft. Keep in mind, however, that these libraries implement a beta version of some SOAP protocols, while WCF (the successor to WSE in many ways) implements the standards by default. Since there were some breaking changes in the protocols (particularly WS-Addressing), you'll have to offer a customBinding endpoint on your WCF service to accommodate.

Unfortunately, I can't tell you which you'll use, as it'll depend on which protocol you want to accommodate on the service, but most of your problems will be solved by changing the messageVersion of the textMessageEncoding for the custom binding. This is not the best scenario, but it could buy you something if you're trying to integrate a client.

Bottom line, there's a lot of work to get a .NET 2.0 client to talk to a WCF service for anything other than basicHttpBinding. In many cases, basicHttpBinding may be enough. For many enterprise scenarios, it will not. I can't speak as to which will help you or not, but it is possible to get it to work -- I've done it successfully.

But it's a big pain. Look for an alternative if you can.

断念 2024-07-23 07:36:52

当然可以 - .NET 3.5 上托管的服务不需要客户端上具有相同版本的 .NET 框架。 哎呀——您甚至可以从 Java 或 PHP 调用这样的服务! 这就是面向服务架构的全部要点! :-)

您需要定义您的服务合同(服务被称为什么;可以调用哪些方法),并且您需要决定如何托管它,例如您可以在什么地址调用该服务,以及哪些参数所需的(例如 HTTP 与 TCP、安全或不安全等) - 即使在 WCF 中,这也是大量的工作。

这里有三篇 WCF 介绍性文章 - 请查看!

但是从 .NET 2.0 客户端调用该服务绝对没有问题!

马克

Yes of course - the service being hosted on .NET 3.5 doesn't require the same version of the .NET framework on the client. Heck - you can even call such a service from Java or PHP! That's the whole POINT of Service Oriented Architecture! :-)

You need to define your service contract (what's the service called; what methods are available to be called on it) and you need to decide how to host it, e.g. at what address can you call this service, and what parameters are required (e.g. HTTP vs. TCP, secured or not secured etc.) - that's a lot of work, even in WCF.

Here are three introductory articles for WCF - check them out!

But calling that service from a .NET 2.0 client is ABSOLUTELY no problem!

Marc

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