默认创建的webservices.asmx是不支持get的,
如
[WebMethod] public string HelloWorld() { return "Hello World"; }
想要看到获取的效果,
需要访问 http://127.0.0.1:8888/services/homeservice.asmx?op=HelloWorld
它有个点击调用的,其实是向该asmx发送post请求,获取到返回数据的,
它post提交的地址是http://127.0.0.1:8888/services/homeservice.asmx/HelloWorld
但在浏览器输入该地址并不能访问到返回数据,因为需要另外配置get支持
具体是,在services/下,建立web.config
<configuration>,<system.web>,中包含以下配置
<webServices> <protocols> <add name="HttpGet"/> <add name="HttpPost"/> </protocols> </webServices>
再次通过,http://127.0.0.1:8888/services/homeservice.asmx/HelloWorld,就可以看到返回的xml
转载于:https://www.cnblogs.com/ijunxiong/p/6684807.html