We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

how to get the response from xml file in the java main class,the xml file is displayed after calling a link

smriti priyanka
on
Medium Priority
43 Views
Last Modified: 2020-05-31
I have a java main class and i want the response of xml file in the string form to pass it as a parameter in the method parseDscList(String) ,I want the response of the xml,here i have to call a link which displays the xml file and response from that file i have to pass to the method, as mentioned above.I am attaching the screen shot of the link which i have to call and it displays the xml file and the main class of java in which i want the response of the xml file.Please provide the solution as soon as possible .Thanks
Attaching the screen shot.java_error.JPGXmlrespMain.JPG
Comment
Watch Question

CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
You will need to read from the server first:

URL url = new URL("https://127.0.0.1:55103/dsc/getCertList"); 
BufferedReader in = new BufferedReader( new InputStreamReader(url.openStream()));
String xml = "";
String inputLine; 
while ((inputLine = in.readLine()) != null) {
   System.out.println(inputLine);
   xml += inputLine;
} 
in.close();
and then
d1.parseDscList(xml);
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
You're connecting to HTTPS, this means you have to have the server's certificate into your cacerts. You have to import it with keytool.

Or you can connect to HTTP (if the server supports it).

Author

Commented:
@grionis What is server certificate and what does it do.I have gone through keytool link provided by you,but unable to understand from where to begin with.what i have to do,from where i will get the certificate etc.I have installed security certificate in my system.Please explain with some example,I am very new to all these. Thanks
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
I gave you the link in my answer above.

Author

Commented:
@grionis What is server certificate and what does it do.I have gone through keytool link provided by you,but unable to understand from where to begin with.what i have to do,from where i will get the server certificate etc.I have installed security certificate in my system.Please explain with some example,I am very new to all these. Thanks
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
The certificate is the one that the site https://127.0.0.1:55103 uses. You have to use the same certificate. Because every time you connect to https://127.0.0.1:55103 you have to send the data encrypted with the certificate of the site. USing certificates is a complex subject for someone new to Java, I'd suggest you get a grasp about SSL and security first, before you attempt to do it.
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
If you type this URL in a browser: http://127.0.0.1:55103/dsc/getCertList what do you get?
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
I think it's redirecting you to HTTPS, so you cannot use the site without HTTPS.

Do you have the SSL certificate in a file? and what java are you using? Can you give me the path of the Java installation?
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
You said

I have installed security certificate in my system 
Where is this file? Can you tell me the full path?

Author

Commented:
@grionis pleaseprovide me the solution.Thanks
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
I need the full path of the certificate on the disk. The screenshot does not help.

Author

Commented:
@grionis How to get the full path of ssl certificate on the disk can u help me.
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
I don't know. How did you install it?

Author

Commented:
@grionis Not getting you.certificate was provided to me.i installed it .

Author

Commented:
@grionis I am attaching the screenshot.it can help you.
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
certificate was provided to me.i installed it .
How was it provided?

Author

Commented:
It was provided to me by the organization in the mail.i downloaded it and installed it in my system.I have already provided u the screenshot.thanks
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
Save it somewhere from your e-mail and let me know of the path.
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
And what is the name of the file? I want the full name (with the extension).
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
Open a command window and type this

C:\Program Files\Java\jre1.8.0_251\bin\keytool -import -alias nfams -file C:\Users\admin\Desktop\NFAMS-Project\Digital_signature\DigitalSignerService 6.1.1 Windows Installers\Pre-Requisites\127.0.0.1.cer -keystore C:\Program Files\Java\jre1.8.0_251\lib\security\cacerts

If it asks you for password type "changeit" without the "

Author

Commented:
Ok .thanks a lot.

Author

Commented:
@girionis Pleasereply.

Author

Commented:
@girionis Any input required please tell.Please provide me solution as soon as possible.
CERTIFIED EXPERT
Distinguished Expert 2019
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.