snajalm
asked on
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
A simple and quick way of performing this would be greatly appreciated!
regards
Not sure exactly what you're asking, but you'd use a POST/GET and read the response in the usual way
ASKER
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...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.xm l" 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.
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.xm
ASKER
Thanks!
:)