WCF、ASMX 基本 HTTP 绑定和 IIS

发布于 2024-09-05 15:40:00 字数 700 浏览 2 评论 0原文

我一直在使用 WCF“自”托管应用程序进行大量工作。最近,我被要求编写一个 Web 服务,其中调用客户端是一个名为“WGET”的基于 Linux 的程序。我想使用 WCF 而不是传统的 ASMX Web 服务。 Web 服务正在返回标准 XML 响应。我不确定这两种技术之间的重点细节,但我知道 WCF 是正确的途径。我创建了一个托管在 IIS 中的 WCF 服务(使用 basicHttpBinding)。

1.) 经典的 ASMX Web 服务(标准 HTTP POST/GET)是否使用 SOAP 来返回响应?我从 XSD 创建了一个用于 Web 服务响应的类。幕后到底发生了什么?是否只有特殊的 XML HTTP 标头知道如何处理响应?响应没有封装在 SOAP 中吗?传统的 ASMX Web 服务与我使用 .Net“XSD”程序生成的类完美配合。

2.) 我想使用 WCF 来提供此服务。使用 basicHttpBinding 有效吗?正如我所读到的,这是用于 ASMX 客户端的正确绑定。它使用 SOAP、标准 HTTP 标头还是其他内容?

3.) 这是一个愚蠢的问题,因为我没有做过很多 Web 服务编程。我注意到 ASMX 默认登录页面上有响应示例和调用功能的代码。当我使用 WCF 创建相同的服务时,我必须创建一个客户端应用程序来执行这些任务。有没有办法像经典的 ASMX 服务一样公开 WCF 端点,或者 WSDL 是唯一的途径吗?

一如既往,我非常感谢您的反馈。

谢谢, 布伦南

I have been doing a lot of work with WCF "self" hosted applications. I recently was requested to write a web service where the calling client was a Linux based program named "WGET". I would like to use WCF instead of a traditional ASMX web service. The web service is returning a standard XML response. I am not sure of the underlining details between the two technologies but I know WCF is the proper route. I created a WCF service to be hosted in IIS ( using basicHttpBinding).

1.) Did classic ASMX web services ( standard HTTP POST/GET) use SOAP to return responses? I created an class from XSD for the web service response. What is really going on behind the scenes? Is there just special XML HTTP headers that know how to handle to response? Is the response not wrapped in SOAP? The traditional ASMX web service worked perfectly with the class I generated using the .Net "XSD" program.

2.) I want to use WCF for this service. Will using basicHttpBinding work? As I have read, that is the correct binding to use for ASMX clients. Does this use SOAP, standard HTTP headers, or something else?

3.) This is a dumb question because I have not done a lot of web service programming. I noticed on the ASMX default landing page there were examples for responses and code to invoke the functionality. When I create the same service using WCF, I had to create a client application to perform these tasks. Is there a way to expose the WCF endpoint like a classic ASMX service or is the WSDL the only route?

As always, I really appreciate the feedback.

Thanks,
Brennan

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

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

发布评论

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

评论(1

我们只是彼此的过ke 2024-09-12 15:40:00

回答您的问题:

1.) 经典的 ASMX Web 服务(标准 HTTP POST/GET)是否使用 SOAP 来
返回响应?

是的。 ASMX 使用 SOAP 1.1 标准,该标准也在 WCF 中实现。

2.) 我想使用 WCF 来提供此服务。将使用 basicHttpBinding
工作?

是的,basicHttpBinding 是模仿 ASMX 服务的完美匹配。它像 ASMX 一样使用 SOAP 1.1,并且其行为应该与 ASMX 非常相似。

3.) 我注意到 ASMX 默认登陆页面上有以下示例
响应和代码来调用
功能。有没有办法
像经典一样公开 WCF 端点
ASMX 服务还是 WSDL 唯一
路线?

WCF 仅显示一个默认页面,让您知道确实存在服务。没有旋钮或选项可以打开以获得相同的 ASMX 样式页面(出于安全原因)。如果您需要的话,您必须自己做这件事。 WSDL / XSD 确实是 WCF 的最佳选择。

To answer your questions:

1.) Did classic ASMX web services ( standard HTTP POST/GET) use SOAP to
return responses?

Yes. ASMX is using the SOAP 1.1 standard, which is implemented in WCF also.

2.) I want to use WCF for this service. Will using basicHttpBinding
work?

The basicHttpBinding is the perfect match for mimicking an ASMX service, yes. It's using SOAP 1.1 just like ASMX, and should behave quite like ASMX.

3.) I noticed on the ASMX default landing page there were examples for
responses and code to invoke the
functionality. Is there a way to
expose the WCF endpoint like a classic
ASMX service or is the WSDL the only
route?

WCF only shows a default page to give you an idea that there is indeed a service. There are no knobs or options to turn on to get the same ASMX-style page (for security reasons). If you need to, you would have to do this yourself. WSDL / XSD is really the way to go with WCF.

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