android httppost xml数据到服务器

时间:2013-10-25 09:30:09

标签: android xml

我无法将xml数据发布到server.i在向服务器执行请求时遇到错误。错误是INTERNAL SERVER ERROR.please帮助我

    public String uploadfiletoserver(String xml)
                int TIMEOUT_MILLISEC = 10000; // = 10 seconds
                HttpParams httpParams = new BasicHttpParams();
                HttpConnectionParams.setConnectionTimeout(httpParams, TIMEOUT_MILLISEC);
                HttpConnectionParams.setSoTimeout(httpParams, TIMEOUT_MILLISEC);
                HttpClient client = new DefaultHttpClient(httpParams);

                HttpPost request = new HttpPost(
                        url_context + "/orders/order");
                try {
                     Log.i("YMApps Res","In try for setting url encoded form");
                    StringEntity entity = new StringEntity(xmlString);
                    entity.setContentType(new BasicHeader(HTTP.CONTENT_TYPE,
                            "application/xml"));
                    request.setEntity(entity);

                    ResponseHandler<String> handler = new BasicResponseHandler();
                    Log.i("YMApps Res","Inside try before execute");
                    return client.execute(request, handler);
                } catch (Throwable e) {
                    Log.i("YMApps Res","Inside catch execute");
                    e.printStackTrace();
                   }
                Log.i("YMApps Res","After try and catch in upload file to server");
                return "";
}

0 个答案:

没有答案