I have written the following function in order to perform an http POST request:
private void httpPost(final File xmlFile){
String textviewresponse;
Thread thread = new Thread(){
@Override
public void run() {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://myURL");
StringEntity entity;
HttpResponse httpresponse;
try {
entity = new StringEntity(xmlFile.toString());
entity.setContentType("text/xml");
Log.d("TAG",httppost.getURI().toString());
httppost.setEntity(entity);
try {
httpresponse = httpclient.execute(httppost);
textviewresponse=EntityUtils.toString(httpresponse.getEntity());
Log.d("TAG",textviewresponse);
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}finally {
httpclient.getConnectionManager().shutdown();
}
} catch (Exception e) {
e.printStackTrace();
}
}
};
thread.start();
}
The problem is that when I send the request, I keep getting the response for the GET method, rather than what I should be getting for a POST.
What might be causing this problem?