寫了一個Web Service,在內網中查看webservice的內容時一切正常,可是用外網查看WebService的時候顯示如下:The test form is only available for requests from the local machine.于是我把這段文字copy下來,google了一下,在Microsoft 技術支持網站上找到了答案:當您嘗試從遠程計算機訪問 Web 服務時,不會顯示“調用”按鈕。并且,您會收到以下錯誤信息:The test form is only available for requests from the local machine
解決方法:通過編輯 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>