Ajax无法调用网络上的WebService,本机可以,什么原因呢?

 HTTP GET and HTTP POST 默认为禁用
概述
This article discusses changes in the .NET Framework 1.1 that affect the HTTP GET method and the HTTP POST method on a Web server. This article also describes workarounds for this new functionality.
这篇文章讨论.NET Framework 1.1所作出的一些改变.这些改变影响了web服务器上的HTTP GET方法和HTTP POST方法.同时,文章也描述了这项功能所适用的场景.
MORE INFORMATION
更多信息
The .NET-connected Web services support HTTP GET, HTTP POST and SOAP protocols. By default, in .NET Framework 1.0, all three protocols are enabled. By default, in .NET Framework 1.1, HTTP GET and HTTP POST are both disabled. This is for security reasons.
有连接的.NET web服务支持HTTP GET,HTTP POST和SOAP 协议,在默认情况下,这3种协议在.NET 1.0中全部被支持,而在.NET 1.1下,出于安全因素,HTTP GET与HTTP POST是被禁用的.

Applications that use HTTP GET or HTTP POST to invoke a Web service fail when the Web service is upgraded to .NET Framework 1.1. These applications receive a
System.Net.WebException
error message that indicates the request format is unrecognized.
Web服务运行在.NET1.1下的时候,应用程序通过HTTP GET或HTTP POST去调用它就会失败.应用程序收到System.Net.WebException的错误信息,这个错误信息表明服务器不能够识别应用程序的请求格式.
Note that the HTML-based test form uses HTTP POST, and therefore the HTML-based test form does not work in .NET Framework 1.1. This is true except on localhost as noted below.
但要注意:基于网页表单
The .NET Framework 1.1 defines a new protocol that is named HttpPostLocalhost. By default, this new protocol is enabled. This protocol permits invoking Web services that use HTTP POST requests from applications on the same computer. This is true provided the POST URL uses http://localhost, not http://hostname. This permits Web service developers to use the HTML-based test form to invoke the Web service from the same computer where the Web service resides.
.NET框架1.1定义了一个名为HttpPostLocalhost的新协议.该协议默认是启用的.他允许应用程序通过HTTP POST协议调用同一计算机上的web服务.调用服务是的请求各个固定为http://localhost,而不能是http://计算机名.这就使得开发人员能够可以用基于网页表单的方式调用处于同一计算机上的web服务.
When you try to access the Web service from a remote computer you do not see the Invoke button. And, you receive the following error message:
The test form is only available for requests from the local machine


当你尝试通过网络上的其他计算机来访问web服务时,却不见”Invoke”按钮,并且收到以下的错误信息:
“testform”只是在本地机上发出请求有效

Workaround
HTTP GET and HTTP POST may be enabled by editing the Web.config file for the vroot where the Web service resides. The following configuration enables both HTTP GET and HTTP POST:
HTTP GET 和 HTTP POST 可以通过编辑Web.config文件使其有效.如下所示:
<configuration> <system.web> <webServices> <protocols> <add name="HttpGet"/> <add name="HttpPost"/> </protocols> </webServices> </system.web> </configuration>
Alternatively, you can enable these protocols for all Web services on the computer by editing the <protocols> section in Machine.config. The following example enables HTTP GET, HTTP POST, and also SOAP and HTTP POST from localhost:
除此之外,你可以配置这些协议对计算机上的所有web服务有效.
<protocols> <add name="HttpSoap"/> <add name="HttpPost"/> <add name="HttpGet"/> <add name="HttpPostLocalhost"/> <!-- Documentation enables the documentation/test pages --> <add name="Documentation"/> </protocols>
Back to the top
REFERENCES
For more information about Web services configuration, see the <protocols> Element in the .NET Framework 1.1 documentation:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值