简体   繁体   English

从Android访问ASP.NET Web服务

[英]Accessing ASP.NET web service from android

I have created a basic web service and I need to access it from android but somehow the web service is only accessible on my local machine, with a local URL like http://localhost:4012/MainWebService.asmx but outside my machine when I try something like 187.120.36.4:4012/MainWebService.asmx the 187.120.36.4 being the IP of my machine hosting the asp.net web service it doesn't go through, all my googling efforts have not paid off so far. 我已经创建了一个基本的Web服务,我需要从android访问它,但是以某种方式,该Web服务只能在本地计算机上访问,并且使用本地URL,例如http:// localhost:4012 / MainWebService.asmx,但是在我的计算机外部尝试类似187.120.36.4:4012/MainWebService.asmx之类的东西187.120.36.4是托管没有通过它的asp.net Web服务的我的机器的IP,到目前为止,我所有的Google搜索工作都没有得到回报。 So any help will be highly appreciated guys and thanks in advance. 因此,任何帮助将受到高度赞赏,并在此先感谢您。

If your machine is connected to a router then you need enable port forwarding on your router to your local machine and then run your web service in your local machine. 如果您的计算机连接到路由器,则需要在路由器上启用端口转发到本地计算机,然后在本地计算机上运行Web服务。

After you have it set up your connect url will be http://<your public ip address>:port number where public ip address is your router's external ip address. 设置好之后,您的连接URL将是http://<your public ip address>:port number ,其中公共IP地址是路由器的外部IP地址。

First you need IIS Server. 首先,您需要IIS服务器。 This is how to enable it on W10. 是在W10上启用它的方法。 Next you need to configure you ASP project to run on the IIS server. 接下来,您需要配置ASP项目以在IIS服务器上运行。 Now you should be able to access your webservice on 187.120.36.4:4012/MainWebService.asmx. 现在,您应该可以访问187.120.36.4:4012/MainWebService.asmx上的Web服务。

BTW. 顺便说一句。 That looks like your external IP. 看起来像您的外部IP。 Are you sure it is correct? 您确定正确吗? I would suspect something like 192.168.x.xxx 我会怀疑像192.168.x.xxx这样的东西

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM