Solved

Fetching server setting xml off HTTPS POST request in Java!

Posted on 2011-09-29
6
242 Views
Last Modified: 2012-05-12
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
Comment
Question by:snajalm
  • 3
  • 2
6 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 36814150
Not sure exactly what you're asking, but you'd use a POST/GET and read the response in the usual way
0
 

Author Comment

by:snajalm
ID: 36814222
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
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 36814290
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
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
LVL 10

Expert Comment

by:gordon_vt02
ID: 36891485
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
 

Author Closing Comment

by:snajalm
ID: 36928677
Thanks!
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 36930294
:)
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to get all the API from website? 11 89
JUnit 4 @Before and @BeforeClass differences 3 59
rhino JavaScript import, load 25 83
Java SE 8u111  Lot of stuff broke 11 69
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
A Change in PHP Behavior with Session Write Short Circuit (http://php.net/manual/en/book.session.php#116217) (Winter 2014)** With the release of PHP 5.6 the session handler changed in a way that many think should be considered a bug.  See the note …
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question