To test the operation using the HTTP POST protocol, click the 'Invoke' button.

来源:互联网 发布:杭州城市骑行大数据 编辑:程序博客网 时间:2024/06/06 02:37
 

测试webservice的时候,如果出现这个错误:"The test form is only available for requests from the local machine"

在web.config中加入以下配置,就可以解决问题。

<system.web>
    
<webServices>
        
<protocols>
          
<add name="HttpGet"/>
          
<add name="HttpPost"/>
        
</protocols>
    
</webServices>
</system.web>
原因:
在.NET Framework v1.0中,可以通过远程访问和测试一个web service,但在v1.1下,出于安全问题,这个远程调用被禁止了(不过还是可以在本地调用)。所以出现这个错误
The test form is only available for requests from the local machine



写了一个Web Service,在内网中查看webservice的内容时一切正常,可是用外网查看WebService的时候显示如下:The test form is only available for requests from the local machine.

当您尝试从远程计算机访问 Web 服务时,不会显示“调用”按钮。并且,您会收到以下错误信息:The test form is only available for requests from the local machine

INFO:默认情况下禁用 HTTP GET 和 HTTP POST

解决方法:通过编辑 Web 服务所在的 vroot 的 Web.config 文件,可以启用 HTTP GET 和 HTTP POST。以下配置同时启用了 HTTP GET 和 HTTP POST:

<configuration>
    <system.web>
    <webServices>
        <protocols>
            <add name="HttpGet"/>
            <add name="HttpPost"/>
        </protocols>
    </webServices>
    </system.web>
</configuration>

或者,可以通过编辑 Machine.config 中的 <protocols> 节为计算机上的所有 Web 服务启用这些协议。下面的示例启用了 HTTP GET、HTTP POST 及 SOAP,此外还从本地主机启用了 HTTP POST:

<protocols>
<add name="HttpSoap"/>
<add name="HttpPost"/>
<add name="HttpGet"/>
<add name="HttpPostLocalhost"/>
      <!-- Documentation enables the documentation/test pages -->
<add name="Documentation"/>
</protocols>

http://www.cnblogs.com/neru/archive/2010/08/12/1797783.html
原创粉丝点击