'Getting connection reset error while getting big response from soap API
Can anyone tell me what I am missing here, same code is working when response size is less. Here in the response getting xls file in encrpypted format. When file size is big, getting connection reset error.
Code to make a webservice HTTP request
String responseString = "";
String outputString = "";
String wsURL = System.getenv("ORACLE_ENDPOINT");
URL url = new URL(wsURL);
URLConnection connection = url.openConnection();
HttpURLConnection httpConn = (HttpURLConnection) connection;
ByteArrayOutputStream bout = new ByteArrayOutputStream();
String xmlInput = requestPayloader(requestId_1, GroupId, RequestId_2, interfaceType);
byte[] buffer = new byte[xmlInput.length()];
buffer = xmlInput.getBytes();
bout.write(buffer);
byte[] b = bout.toByteArray();
String SOAPAction = "url";
// Set the appropriate HTTP parameters.
// refer username and password from Key Valut
KeyVault keyVault = new KeyVault();
String userName = keyVault.GetSecretFromVault(System.getenv("ORACLE_ENDPOINT_USERNAME"));
String password = keyVault.GetSecretFromVault(System.getenv("ORACLE_ENDPOINT_PASSWORD"));
// String auth = System.getenv("ORACLE_ENDPOINT_USERNAME") + ":" +
// System.getenv("ORACLE_ENDPOINT_PASSWORD");
String auth = userName + ":" + password;
byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(StandardCharsets.UTF_8));
String authHeaderValue = "Basic " + new String(encodedAuth);
httpConn.setRequestProperty("Content-Type", "application/soap+xml");
httpConn.setRequestProperty("SOAPAction", SOAPAction);
httpConn.setRequestProperty("Authorization", authHeaderValue);
httpConn.setRequestMethod("POST");
httpConn.setDoOutput(true);
httpConn.setDoInput(true);
httpConn.setReadTimeout(0);
OutputStream out = httpConn.getOutputStream();
out.write(b);
//out.close();
InputStreamReader isr = new InputStreamReader(httpConn.getInputStream());
BufferedReader in = new BufferedReader(isr);
while ((responseString = in.readLine()) != null) {
outputString = outputString + responseString;
}
return outputString;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
