私は、postメソッドを使用して2つのxmlをパラメーターとしてサーバーに送信する必要があるAndroidプロジェクトに取り組んでいます(つまり、フォームとして送信したい)。次のコードを使用してデータを送信しようとしましたが、機能しません。リモートデータベースにデータがありません。
private void postFormData(List<DataItem> ti,String ex,String getExpensesXml)
{
//Create a new Http Client
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(url);
try
{
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("sync","true"));
nameValuePairs.add(new BasicNameValuePair("tt",ti));
nameValuePairs.add(new BasicNameValuePair("te",ex));
UrlEncodedFormEntity form;
form = new UrlEncodedFormEntity(nameValuePairs,"UTF-8");
httppost.setEntity(form);
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
String line = EntityUtils.toString(entity);
System.out.println(line);
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
何が問題なのかわかりませんでした。誰かが問題を見つけて私に解決策を提案することができれば素晴らしいでしょう。
もう2つ質問がありますか?正しいコードを試していますか?フォームを介してxmlデータをサーバーに送信する他の方法はありますか?
前もって感謝します