美文网首页
2020-07-10 WebService支持Post和Get方

2020-07-10 WebService支持Post和Get方

作者: 1f658716b568 | 来源:发表于2020-07-10 10:11 被阅读0次

    WebService支持Post和Get方法

    在WebService的测试页面,你看到了什么?SOAP1.1/SOAP1.2/HTTP POST三种方法的测试页面,但是事实上,此时你用POST方法是无法访问这个webservice的,更不用说GET了。.NET2.0下的所有新建webservice默认关闭了这两种方法,是为了安全考虑。

    但是我们有的时候不得不使用这两种方法,特别是GET方法,几乎由一切软件和编程方法支持,并且可以穿越几乎所有的防火墙(除非连WEB访问都不让,那是中情局吧……)。那么如何让部署起来的WebService支持这种方法呢?

    在webservice的目录下添加Web.config文件(如果已经存在就修改之),最简单的情况,我们需要这样的文件:

    <?xml version="1.0"?> <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"> <system.web> <compilation defaultLanguage="c#" debug="true"/> <webServices> <protocols> <add name="HttpGet"/> <add name="HttpPost"/> </protocols> </webServices> </system.web> </configuration>

    如果你已经有了VS生成的Web.config,那么只需要修改或添加这么一段

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

    相关文章

      网友评论

          本文标题:2020-07-10 WebService支持Post和Get方

          本文链接:https://www.haomeiwen.com/subject/ywspcktx.html