由于我是 android 新手,请提供教程的链接以在服务器上发布 xml 数据。我面临的问题是执行发布请求
public void uploadFileToServer()
{
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(url_context + "/orders/order");
httppost.addHeader("Accept", "text/xml");
httppost.addHeader("Content-Type", "application/xml");
try
{
StringEntity entity = new StringEntity(xmlString, "UTF-8");
entity.setContentType("application/xml");
httppost.setEntity(entity);
HttpResponse response = httpClient.execute(httppost);
BasicResponseHandler responseHandler = new BasicResponseHandler();
String strResponse = null;
if (response != null)
{
try {
strResponse = responseHandler.handleResponse(response);
} catch (HttpResponseException e)
{
e.printStackTrace();
} catch (IOException e)
{
e.printStackTrace();
}
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
}