File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Sockets and Internet Protocols and the fly likes Read XML output from a URL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Read XML output from a URL" Watch "Read XML output from a URL" New topic
Author

Read XML output from a URL

Arti Soni
Greenhorn

Joined: May 04, 2007
Posts: 9
Hi,
I am trying to make a connection using HttpURLConnection to make connection to a URL and read the resulting XML output. Am getting a connection timed out error or connection refused error if the URL is given as http and not https. The following is the code -

URL url = new URL( urlString );

URLConnection URLconnection =
url.openConnection ( ) ;
HttpURLConnection httpConnection =
(HttpURLConnection)
URLconnection;

int responseCode =
httpConnection.getResponseCode ( ) ;
if ( responseCode ==
HttpURLConnection.HTTP_OK) {
InputStream in =
httpConnection.getInputStream ( ) ;
}

Can someone please help me in reading an XML response obtained from a secure URL.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42371
    
  64
Can you retrieve the XML by typing the URL into a browser on the machine where you are running this code?


Ping & DNS - my free Android networking tools app
 
jQuery in Action, 2nd edition
 
subject: Read XML output from a URL