.net HTTP SOAP\GET\POST
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4646146/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
HTTP SOAP\GET\POST
提问by milan_9211
I created my first web service 2 days ago in VS 2008 and was thinking about consuming it when I came across the following questions about web services:
两天前,我在 VS 2008 中创建了我的第一个 Web 服务,当我遇到以下有关 Web 服务的问题时,我正在考虑使用它:
1) My web service Test Invocation page(canned page which comes as a part of .NET framework) does not displays any sample HTTP GET request\response messages. The only messages it displays are of HTTP POST, SOAP 1.1 and SOAP 1.2 . Shall I assume that web services are some how not encouraging the use of HTTP GET protocol for calling them?
1) 我的 Web 服务测试调用页面(作为 .NET 框架的一部分提供的固定页面)不显示任何示例 HTTP GET 请求\响应消息。它显示的唯一消息是 HTTP POST、SOAP 1.1 和 SOAP 1.2 。我是否应该假设 Web 服务不鼓励使用 HTTP GET 协议来调用它们?
2) To make an HTTP-POST call through browser, I created a sample html page. Can I do the same to make sample HTTP-SOAP call as well? If yes, would the response be in SOAP format? Can anyone send me such an html page.
2) 为了通过浏览器进行 HTTP-POST 调用,我创建了一个示例 html 页面。我也可以做同样的事情来进行示例 HTTP-SOAP 调用吗?如果是,响应是否为 SOAP 格式?任何人都可以向我发送这样的 html 页面。
3) How do we send Host Header information while make a call to web service through a browser?
3) 如何在通过浏览器调用 Web 服务的同时发送 Host Header 信息?
4) Why do we call it a 'HTTP-SOAP call' when we make a call to web service using POST method(method='post')?
4) 当我们使用 POST 方法(method='post')调用 Web 服务时,为什么我们称它为“HTTP-SOAP 调用”?
5) Why HTTP-SOAP should take precedence over HTTP-GET and HTTP-POST?
5) 为什么 HTTP-SOAP 应该优先于 HTTP-GET 和 HTTP-POST?
Thanks and Regards' Milan
感谢和问候的米兰
回答by Ladislav Mrnka
Standard SOAP services are using only HTTP POST because they require complex SOAP request (XML) which cannot be included in query string.
标准 SOAP 服务仅使用 HTTP POST,因为它们需要无法包含在查询字符串中的复杂 SOAP 请求 (XML)。
When you want to make call to your SOAP service from web page, your page must built valid SOAP request. Because of that, SOAP calls are usually created from auto-generated service clients on server side.
当您想从网页调用 SOAP 服务时,您的页面必须构建有效的 SOAP 请求。因此,SOAP 调用通常是从服务器端自动生成的服务客户端创建的。
We can call it HTTP-SOAP because it is a SOAP request transported by the HTTP protocol with POST method.
我们可以称它为 HTTP-SOAP,因为它是通过 HTTP 协议使用 POST 方法传输的 SOAP 请求。
It doesn't take precedence. It is how SOAP services usually work. If you want to use HTTP GET and HTTP POST you should check REST services.
它不优先。这就是 SOAP 服务通常的工作方式。如果您想使用 HTTP GET 和 HTTP POST,您应该检查 REST 服务。
回答by John Saunders
First of all, you may have made a mistake. Did you create a service with a .ASMX extension?
首先,你可能犯了一个错误。您是否创建了扩展名为 .ASMX 的服务?
That is a legacy "ASMX" web service, and should not be used for new development unless you have no choice. WCF should be used for all new development.
这是一个遗留的“ASMX”Web 服务,除非您别无选择,否则不应将其用于新的开发。WCF 应该用于所有新的开发。
Second, GET cannot be used to send complex types to the service, as it places the parameters into the query string. POST, is actually of little use, except for the test page (it also cannot send complex types).
其次,GET 不能用于向服务发送复杂类型,因为它将参数放入查询字符串中。POST,其实没什么用,除了测试页(它也不能发送复杂类型)。
The only thing that really matters for such a service is SOAP. You should create a client application of some kind to test it, perhaps a set of unit tests.
对于此类服务,唯一真正重要的是 SOAP。您应该创建某种客户端应用程序来测试它,也许是一组单元测试。

