1. 程式人生 > >通過URL傳參訪問webservice

通過URL傳參訪問webservice

webservice的方法 如上 

http://192.168.1.2:8055/TECPrinterWebService/TECPrinterWebService.asmx/testLblPrint?flag=1

想通過上面URL 呼叫方法 獲得返回值的話 

需要在 Web.config 裡面 加上 一段程式碼 

<webServices>
      <protocols>
        <add name="HttpPost" />
        <add name="HttpGet" />
        <add name="HttpSoap" />
        <add name="Documentation" />
      </protocols>
</webServices>

備註

在web站點的web.config的<system web>...</system web>內增加元素標籤:

原理剖析:
通過http請求訪問webservice有三種方式,在ie中輸入url並傳參的方式屬於http-get方式。通過增加web.config配置,實現允許get請求即可。