Im trying to read a json and send it back to a server in the form of XML. Im able to read the json successfully but i need to send a xml from what i have read which is in my endpoint
URL url = new URL("https://xxxx.xxx/xxxx/post");
HttpURLConnection http = (HttpURLConnection)url.openConnection();
http.setRequestMethod("POST");
http.setDoOutput(true);
http.setRequestProperty("Content-Type", "application/xml");
http.setRequestProperty("Accept", "application/xml");
String data = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Request>\n <Login>login</Login>\n
<Password>password</Password>\n</Request>";
byte[] out = data.getBytes(StandardCharsets.UTF_8);
OutputStream stream = http.getOutputStream();
stream.write(out);
System.out.println(http.getResponseCode() + " " + http.getResponseMessage());
http.disconnect();
Currently im hardcoding string data, but i want to send the data which is in my rest endpoint http://localhost:8080/login if i hit this endpoint im getting a XML
<ArrayList>
<item>
<Login>1000<Login>
<Password>Pwd<Password>
</item>
</ArrayList>
How can i read this endpoint and use as String data