寫了一個(gè)Web Service,在內(nèi)網(wǎng)中查看webservice的內(nèi)容時(shí)一切正常,可是用外網(wǎng)查看WebService的時(shí)候顯示如下:The test form is only available for requests from the local machine.于是我把這段文字copy下來,google了一下,在Microsoft 技術(shù)支持網(wǎng)站上找到了答案:當(dāng)您嘗試從遠(yuǎn)程計(jì)算機(jī)訪問 Web 服務(wù)時(shí),不會顯示“調(diào)用”按鈕。并且,您會收到以下錯(cuò)誤信息:The test form is only available for requests from the local machine
解決方法:通過編輯 Web 服務(wù)所在的 vroot 的 Web.config 文件,可以啟用 HTTP GET 和 HTTP POST。以下配置同時(shí)啟用了 HTTP GET 和 HTTP POST:
<configuration>
<system.web>
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
</system.web>
</configuration>
或者,可以通過編輯 Machine.config 中的 <protocols> 節(jié)為計(jì)算機(jī)上的所有 Web 服務(wù)啟用這些協(xié)議。下面的示例啟用了 HTTP GET、HTTP POST 及 SOAP,此外還從本地主機(jī)啟用了 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>