문제

  1. I am calling this service method in android emullator in Titanium project.
  2. Getting proper response
  3. Then again calling this service method with diffrent data.
  4. Getting the same response(which I got in step 2)
  5. second request not reached to the server
  6. Some how prvious response sitting in cache memmory and giving same response
  7. Any parameter needs be set here?

Note : I have wrote this code as a Titanium Module Project and called from Titanium project.

protected final void callService(final byte[] data) throws IOException {
    OutputStream outputStream = null;
    DataOutputStream output = null;
    InputStream inputStream = null;
    String stringdata = "";
    try {

    String url = "http://localhost:8080/myproject/testService.do"
    HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
    urlConnection.setRequestProperty("Cookie", sessionId);
    urlConnection.setRequestMethod("POST");
    urlConnection.setDoInput(true);
    urlConnection.setDoOutput(false);
    urlConnection.setReadTimeout(200000);
    urlConnection.setConnectTimeout(200000);
    urlConnection.connect();

        outputStream = urlConnection.getOutputStream();
        output = new DataOutputStream(outputStream);
        // write the file data
        if (data != null) {
            output.write(data);
            stringdata = new String(data);
            Log.iTimer(TAG, "Data uploded to the server stream");
        }
        inputStream = connection.getInputStream();
        String outData = inputStream.toString();
        System.out.print(outData);
    } catch (Exception exception) {
        e.printStackTrace();
    } finally {
        if (output != null) {
            output.flush();
            // Close Output stream
            output.close();
        }
        if (outputStream != null) {
            outputStream.close();
        }
    }
}
도움이 되었습니까?

해결책

Not sure if it helps here but you can try this:

urlConnection.setUseCaches(false);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top