|
今天利用vs.net2005(C#) 开发了一个web service
地址:http://192.168.0.203/webservice1/service.asmx
这个地址在本地可以正常使用,但是在远程电脑上不能使用,提示“只能本地测试”,没有调用按钮
如果想在远程可以正常调用,需要修改web.config,在system.web节下面加上下面一段话即可
<webServices > <protocols > <add name="HttpSoap"/> <add name="HttpPost"/> <add name="HttpGet"/> <add name="Documentation"/> </protocols> </webServices>
在我印象中vs.net2003好像没这么麻烦,这估计和vs.net2005的安全级别有关系。
顺便写一个利用web service获取客户端IP的例子
[WebMethod(Description = "通过Web service获取客户端的IP")] public string GetIP() { string ip; if (Context.Request.ServerVariables["HTTP_VIA"] != null) { ip = Context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString(); } else { ip = Context.Request.ServerVariables["REMOTE_ADDR"].ToString(); } return ip; }
|