网络参考和服务参考之间的区别?

发布于 2024-07-09 03:16:52 字数 45 浏览 5 评论 0原文

WCF 中的 Web 引用和服务引用有什么区别? WCF 中哪一个更可取?

What is the difference between web reference and service reference in WCF?
Which is preferable in WCF?

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

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

发布评论

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

评论(5

小ぇ时光︴ 2024-07-16 03:16:53

服务引用是较新的接口,用于添加对所有方式的 WCF 服务(它们可能不是 Web 服务)的引用,而 Web 引用特别关注 ASMX Web 引用。

您可以通过添加服务参考中的高级选项访问网络参考(如果我没记错的话)。

我会使用服务引用,因为据我了解,它是两者中较新的机制。

The service reference is the newer interface for adding references to all manner of WCF services (they may not be web services) whereas Web reference is specifically concerned with ASMX web references.

You can access web references via the advanced options in add service reference (if I recall correctly).

I'd use service reference because as I understand it, it's the newer mechanism of the two.

节枝 2024-07-16 03:16:53

服务引用处理端点和绑定,它们是完全可配置的。 它们允许您通过任何传输协议(HTTP、TCP、共享内存等)将客户端代理指向 WCF

。它们旨在与 WCF 配合使用。

如果您使用 WebProxy,那么您几乎就必须使用 WCF over HTTP

Service references deal with endpoints and bindings, which are completely configurable. They let you point your client proxy to a WCF via any transport protocol (HTTP, TCP, Shared Memory, etc)

They are designed to work with WCF.

If you use a WebProxy, you are pretty much binding yourself to using WCF over HTTP

兔姬 2024-07-16 03:16:53

需要考虑的另一点是,服务接口的新 UI 将为您提供更多创建代理类的灵活性。 例如,它允许您将数据契约映射到现有的 dll(如果它们匹配)(实际上这是默认行为)。

Another point to take in consideration is that the new UI for Service Interface will give you much more flexibility on how you want to create your proxy class. For example, it will allow you to map data contracts to existing dlls, if they match (actually this is the default behaviour).

蓝海似她心 2024-07-16 03:16:52

这里的低级答案是,Web 引用将创建一个客户端代理类,该类允许您的代码与通过 WSDL 描述的 Web 服务对话,并通过 SOAP 或 HTTP GET 进行通信(其他海报表明它只是 ASMX,但是Web 参考还可以与基于 Java 的 Web 服务或基于 Python 或 Ruby 的 Web 服务进行交互,只要它们都使用 WSDL 并符合 WS-I 互操作性标准即可。

服务引用将创建一个与基于 WCF 的服务通信的客户端代理类:无论该 WCF 服务是否是 Web 服务。

The low-level answer here is that a Web Reference will create a client proxy class that allows your code to talk to a Web Service that is described via WSDL and communicates via SOAP or HTTP GET (other posters indicate that it is only ASMX, but Web References can also talk to Java-based Web Services or Python-based or Ruby so long as they all talk WSDL and conform to the WS-I interoperability standard).

A Service Reference will create a client proxy class that communicates with a WCF-based service : regardless of whether that WCF service is a Web Service or not.

寄意 2024-07-16 03:16:52

Web 参考允许您与基于实现 WS-I Basic Profile 1.1 的任何技术的任何服务进行通信,并将相关元数据公开为 WSDL。 在内部,它使用客户端的 ASMX 通信堆栈。

服务参考允许您与基于实现 WCF 支持的众多协议(包括但不限于 WS-I 基本配置文件)中的任何协议的任何技术的任何服务进行通信。 在内部,它在客户端使用 WCF 通信堆栈。

请注意,这两个定义都非常广泛,并且都包含不是用 .NET 编写的服务。

只要 WCF 端点使用 basicHttpBinding 或某些兼容的自定义变体,就完全有可能(尽管不推荐)添加指向 WCF 服务的 Web 引用。

还可以添加指向 ASMX 服务的服务引用。 在编写新代码时,您应该始终使用服务引用,因为它更加灵活且面向未来。

A Web Reference allows you to communicate with any service based on any technology that implements the WS-I Basic Profile 1.1, and exposes the relevant metadata as WSDL. Internally, it uses the ASMX communication stack on the client's side.

A Service Reference allows you to communicate with any service based on any technology that implements any of the many protocols supported by WCF (including but not limited to WS-I Basic Profile). Internally, it uses the WCF communication stack on the client side.

Note that both these definitions are quite wide, and both include services not written in .NET.

It is perfectly possible (though not recommended) to add a Web Reference that points to a WCF service, as long as the WCF endpoint uses basicHttpBinding or some compatible custom variant.

It is also possible to add a Service Reference that points to an ASMX service. When writing new code, you should always use a Service Reference simply because it is more flexible and future-proof.

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