params [0]存储在.net框架中创建的webservice的用户。所以在我的web方法中有两个参数" StartIndex"和" EndIndex"那么现在我如何将一个参数传递给android中的Web方法。
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost( params[0]);
HttpResponse response = client.execute(post);
答案 0 :(得分:3)
您可以使用NameValuePair
列表将多个参数放入POST请求中,如:
try {
HttpPost httpPost = new HttpPost("url");
List<NameValuePair> parameters = new ArrayList<NameValuePair>(2);
parameters.add(new BasicNameValuePair("login", "trout"));
parameters.add(new BasicNameValuePair("password", "salmon"));
httpPost.setEntity(new UrlEncodedFormEntity(parameters, "UTF-8"));
HttpClient httpClient = new DefaultHttpClient();
HttpResponse httpResponse = httpClient.execute(httpPost);
String response = EntityUtils.toString(httpResponse.getEntity(), "UTF-8");
} catch (UnsupportedEncodingException e) {
} catch (ClientProtocolException e) {
} catch (IOException e) {
}