Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

i am getting HttpHostConnectException

 
sam liya
Ranch Hand
Posts: 1240
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
below is my activity class.


exception that i am getting is below.



I don't know why it refused,anyway when i type the below url in browser it gives the results.



given output
 
Maneesh Godbole
Saloon Keeper
Posts: 11027
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
org.apache.http.conn.HttpHostConnectException: Connection to http://192.168.1.2:9763 refused

What happens when you point your phone browser to this URL?
 
sam liya
Ranch Hand
Posts: 1240
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it gives beloww exception.



anyway below url is host in my local machine,which i run this example
 
Maneesh Godbole
Saloon Keeper
Posts: 11027
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

You need to ensure your host server is accessible from your android device/emulator

Are you running on emulator or real device?
 
sam liya
Ranch Hand
Posts: 1240
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am testing on my phone.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And the phone is on the same network as that host? That's an internal IP address that wouldn't otherwise be reachable.
 
sam liya
Ranch Hand
Posts: 1240
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
phone is not in that network i think.Given url is provided by Wso2 Data service server.It's in localhost for my machine.so phone is not in same network.
 
sam liya
Ranch Hand
Posts: 1240
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I ran with emulater.So when i debug,i got below as a String readTwitterFeed in line No 53.But when i continuing debug it gives me a Exception.



Below is exception

>

how to show these data ?
 
Maneesh Godbole
Saloon Keeper
Posts: 11027
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You cannot treat XML as JSON. You will need to convert it explicitly to JSON. Either you write the code to convert or use some existing libraries.
Googling for "android xml to json" gave me promising results
 
sam liya
Ranch Hand
Posts: 1240
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you tell me how to extract data from gives type.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you searched for the phrase Maneesh suggested, what results did you get? Which of those did you try?
 
sam liya
Ranch Hand
Posts: 1240
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
anyway what is the best method to get data from web service in android ?
JSON,REST or any other way
 
Maneesh Godbole
Saloon Keeper
Posts: 11027
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sameera liyanage wrote:anyway what is the best method to get data from web service in android ?
JSON,REST or any other way

I think you might not mean and realize it, but you are coming off as condescending.
Ulf asked you something and your reply is in the format "Anyway....."

You have already been given the answer
Maneesh Godbole wrote:Googling for "android xml to json" gave me promising results
 
sam liya
Ranch Hand
Posts: 1240
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes Maneeshwhen i search i found serveral examples.one is below.

http://www.vogella.com/articles/AndroidJSON/article.html

i used same code.please assist.
 
Maneesh Godbole
Saloon Keeper
Posts: 11027
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sameera liyanage wrote:
i used same code.please assist.

Assist in what? We already pointed out to you that your input is xml which you are trying to treat as JSON. It is not going to work. We also pointed out to you that you need to convert the xml to json before processing it as JSON.

Beyond this, besides, writing the code for you, I do not see what more assistance can we offer.
 
sam liya
Ranch Hand
Posts: 1240
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i change to the code as below .then it gives error.



error


I have already added json-lib-2.4-jdk15 jar file to tge project.

http://answers.oreilly.com/topic/278-how-to-convert-xml-to-json-in-java/
anyway what is dependancy in above url ?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic