与呼叫使用IP网络服务异常 [英] Exceptions with calling web service using IP

查看:122
本文介绍了与呼叫使用IP网络服务异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用的'localhost'或127.0.0.1我的机器上调用Web服务,我得到异常。但是,如果我给公网IP,它工作正常。为什么是怎么回事?

when I call web service from my machine using 'localhost' or 127.0.0.1 , I got exception. But if I give the public IP, it works fine. Why it is happening?

而且,如果用我的公网IP​​,我无法访问Web服务。但如果我把同样的code在另一台机器,并使用该机器的IP地址调用Web服务,它工作正常。

And also, If I use my public IP, I can't access web service. But If I put the same code in another machine, and call that web service using the IP address of that machine, It works fine.

 //working fine

 url = new URL("http://192.168.50.122/NewsLetter/subscribing.php?register="+xmlString);

 //got Exception
 url = new URL("http://localhost/NewsLetter/subscribing.php?register="+xmlString);

//got Exception
 url = new URL("http://127.0.0.1/NewsLetter/subscribing.php?register="+xmlString);

 //got Exception with my public IP - 192.168.50.117
 url = new URL("http://192.168.50.117/NewsLetter/subscribing.php?register="+xmlString);

请帮我...我是想了很多,但不可能解决这个问题。

Please help me... I was trying a lot, but could not solve it.

感谢您....

推荐答案

至于本地主机而言,如果您使用的是仿真器阅读下面的链接...

As far as localhost is concerned, read the following link if you're using an emulator...

谈到从模拟环境到localhost

http://developer.android.com/guide/appendix/faq/commontasks.html#localhostalias

我不知道你的其他问题,但是。

I'm not sure about your other issues, however.

这篇关于与呼叫使用IP网络服务异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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