1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
public void postData(String xmlData,String DestinationUrl)
{ // Create a new HttpClient and Post Header
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(DestinationUrl);
StringEntity se;
try {
se = new StringEntity( xmlData, HTTP.UTF_8);
se.setContentType("text/xml");
httppost.setEntity(se);
try {
httpclient.execute(httppost);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
org.apache.http.HttpResponse httpresponse = null;
try {
httpresponse = httpclient.execute(httppost);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
HttpEntity resEntity = httpresponse.getEntity();
// tvData.setText(EntityUtils.toString(resEntity));
} |