Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 261
  • Last Modified:

Fetching server setting xml off HTTPS POST request in Java!

I simply want to run an https URL request in java and fetch the generated XML as a result of running this URL as I would on a b rowser.  I have already set up for the URL to run on the server but don't know how to fetch the XML file it pops out which are meant to be "server settings".  

A simple and quick way of performing this would be greatly appreciated!

regards
0
snajalm
Asked:
snajalm
  • 3
  • 2
1 Solution
 
CEHJCommented:
Not sure exactly what you're asking, but you'd use a POST/GET and read the response in the usual way
0
 
snajalmAuthor Commented:
I just wan to read the output into an associcated XML file!  I don't know how to read the stream and put it in the client's local disk (not on the server).  Since I'm new to Java, I'm a bit confused as to how this process is handled!  Yeah, I'm talking about that simple process...
0
 
CEHJCommented:
For URLConnection 'conn'

http://technojeeves.com/joomla/index.php/free/51-copying-streams
IOUtils.copyStream(conn.getInputStream(), new FileOutputStream("x.xml"));

Open in new window

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
gordon_vt02Commented:
Is this the scenario you're looking for?

Client connects to Server -> Server connects to other server, retrieving XML file -> Server sends XML file back to Client -> Client saves XML file to disk

If so, all you need to do is create a Servlet that connects to the external URL.  Then set the response header "content-type: attachment;filename=XXX.xml" and that should trigger the 'Save As' dialog in most browsers.  Connect to the URL from your Servlet and, instead of copying the URL's input stream to a FileOutputStream, copy it to the OutputStream of the HttpServletResponse object.  Once you close that stream, the data will be sent back to the client.
0
 
snajalmAuthor Commented:
Thanks!
0
 
CEHJCommented:
:)
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now