This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 39547
    
  27
Can you retrieve the XML by typing the URL into a browser on the machine where you are running this code?


Ping & DNS - updated with new look and Ping home screen widget
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Read XML output from a URL
 
Similar Threads
Problems connecting to LDAP from Weblogic Server: BAD_CERTIFICATE error!
Http Post
Yahoo chat client, any ideas.......
Invoking webservice- Server returned HTTP response code: 500
Issue with sending xml jaxb object to servlet body