• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

i am getting HttpHostConnectException

 
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
shawn peter
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
shawn peter
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am testing on my phone.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
shawn peter
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
shawn peter
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
shawn peter
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can you tell me how to extract data from gives type.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you searched for the phrase Maneesh suggested, what results did you get? Which of those did you try?
 
shawn peter
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
shawn peter
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
shawn peter
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic