Solved

Fetching server setting xml off HTTPS POST request in Java!

Posted on 2011-09-29
6
247 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

733 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