从android拒绝本地主机URL连接 [英] Local Host URL connection refused from android

查看:109
本文介绍了从android拒绝本地主机URL连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个小问题,我正在开发Web服务我有一个url(使用LocalHost)它在浏览器中工作正常时尝试从android连接显示连接拒绝localhost

示例Url:

http:// localhost:33396 / MainWEB.svc / DEChannel



当我在浏览器中打开它的工作正常但这是URL android它的异常连接被拒绝..有些人可以帮我解决这个问题

Hi, one small question, am working on web service i have one url(with LocalHost) its working fine in browser when trying to connect from android its showing connection refused to localhost
Example Url:
http://localhost:33396/MainWEB.svc/DEChannel

this is URL when i open in browser its working fine but from android its getting exception connection refused..some body can help me on this

推荐答案

当然不会。图中显示了虚拟化



Of course it won't. Here comes the virtualization in picture.

引用:

Android将无法与Visual Studio的开发服务器通信,因此您需要在IIS上部署您的服务,并在本地系统IP地址的帮助下,为Android提供DNS。

Android will not be able to communicate with Visual Studio's Development Server, hence you would be required to deploy your services at IIS and with help from your local system IP address, provide DNS to Android.





你的android模拟器是一个不同的设备(或者更确切地说,我说,运行Android操作系统的设备)在同一台机器上运行,该机器已经运行了操作系统。

让我举一个简单的例子来理解这一点,你的机器将有任何IP地址,但这个模拟器-AVD也会有IP地址,这与你的机器不一样。



因此它不会访问您机器上的任何资源。如果您在模拟器本身上运行此URL http:// localhost:33396 / MainWEB.svc ,则无法在本地计算机的浏览器中运行。



如果您在我的回答中注意到了URL,它包含机器的IP地址。



因此,在本地IIS上托管您的WCF服务,从IIS访问此服务。然后,您将获得服务URL,将localhost替换为您的机器IP,并由AVD接受。例如,URL将是 http://192.175.21.15/MainWEB.svc/



您可以从IIS获得托管WCF的帮助,

http://msdn.microsoft.com/en-us/library/ms733766(v = vs.110)的.aspx [ ^ ]

A关于如何托管WCF服务的初学者教程(IIS托管和自托管) [ ^ ]

创建,主机(自托管,IIS托管)和消费WCF服务 [ ^ ]



希望你明白了! :)



-KR



You android emulator is a different device (or rather I'd say, device running the android OS) that runs on the same machine, which already have OS running on it.
Let me give you one simple example to understand this, your machine would have any IP address, but this emulator-AVD also would have the IP address, which is not as same as you machine's.

So it won't access any of the resources from your machine. If you're running this URL http://localhost:33396/MainWEB.svc on emulator itself, it won't work but in your local machine's browsers.

If you might have noticed the URL in my answer, it consist of machine's IP address.

So host your WCF service on your local IIS, access this service from IIS. Then you'd get service URL replacing localhost with your machine IP and that is accepted by AVD. For example URL would be, http://192.175.21.15/MainWEB.svc/.

You can get a help for hosting the WCF on IIS from,
http://msdn.microsoft.com/en-us/library/ms733766(v=vs.110).aspx[^]
A Beginner's Tutorial on How to Host a WCF Service (IIS Hosting and Self Hosting)[^]
Create, Host (Self Hosting, IIS hosting) and Consume WCF Service[^]

Hope you got the idea ! :)

-KR


这篇关于从android拒绝本地主机URL连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆