aspose file tools*
The moose likes Android and the fly likes i am getting HttpHostConnectException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Android
Bookmark "i am getting HttpHostConnectException" Watch "i am getting HttpHostConnectException" New topic
Author

i am getting HttpHostConnectException

sam liya
Ranch Hand

Joined: Nov 25, 2008
Posts: 1225
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

Joined: Jul 26, 2007
Posts: 10535
    
    9

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?


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
sam liya
Ranch Hand

Joined: Nov 25, 2008
Posts: 1225
it gives beloww exception.



anyway below url is host in my local machine,which i run this example
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10535
    
    9


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

Joined: Nov 25, 2008
Posts: 1225
I am testing on my phone.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42946
    
  70
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

Joined: Nov 25, 2008
Posts: 1225
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

Joined: Nov 25, 2008
Posts: 1225
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

Joined: Jul 26, 2007
Posts: 10535
    
    9

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

Joined: Nov 25, 2008
Posts: 1225
can you tell me how to extract data from gives type.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42946
    
  70
When you searched for the phrase Maneesh suggested, what results did you get? Which of those did you try?
sam liya
Ranch Hand

Joined: Nov 25, 2008
Posts: 1225
anyway what is the best method to get data from web service in android ?
JSON,REST or any other way
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10535
    
    9

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

Joined: Nov 25, 2008
Posts: 1225
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

Joined: Jul 26, 2007
Posts: 10535
    
    9

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

Joined: Nov 25, 2008
Posts: 1225
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 ?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: i am getting HttpHostConnectException