Im using Java HTTP webservice client for requesting to server as POST (using text/xml request format). Actually its working fine in my system. But, in Server side they couldnt get any request from my side. Server is not in our control (its government related server and they are using SSL/TLS handshake for security). Server team provided the keys for handshake.
Actually I dont know how to use SSL/TLS and how to add this in my code. Server team told, they will receive the request after handshake success.
I'm stuck now. Adding Certificate on my Tomcat server is needed? How to add SSL handshake in my request?? If anyone know SSL/TLS handshake , please help me with hints.
Thanks in advance..
My Codes are following :
public File sendRequest(File req_xml, String responseFileName) {
File xmlFile = new File(responseFileName);
try {
OutputStream outputStream = new FileOutputStream(xmlFile);
HttpClient httpClient = new org.apache.commons.httpclient.HttpClient();
httpClient.getParams().setParameter("http.useragent",
"Web Service Test Client");
BufferedReader br = null;
PostMethod methodPost = new PostMethod("http://192.168.1.53:8080/MyApplication/service");
try {
methodPost.setRequestBody(new FileInputStream(req_xml));
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}
methodPost.setRequestHeader("Content-Type", "text/xml");
try {
int returnCode = httpClient.executeMethod(methodPost);
if (returnCode == HttpStatus.SC_NOT_IMPLEMENTED) {
System.out
.println("The Post method is not implemented by this URI");
methodPost.getResponseBodyAsString();
} else {
br = new BufferedReader(new InputStreamReader(
methodPost.getResponseBodyAsStream()));
int read = 0;
byte[] bytes = new byte[1024];
while ((read = methodPost.getResponseBodyAsStream().read(
bytes)) != -1) {
outputStream.write(bytes, 0, read);
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
methodPost.releaseConnection();
if (br != null)
try {
br.close();
} catch (Exception fe) {
fe.printStackTrace();
}
}
} catch (FileNotFoundException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
return xmlFile;
}