新手问题
public void onClick(View v) {
final String SERVER_URL="http://localhost/androidserver/Ws.asmx?op=GetUserList";
HttpPost request = new HttpPost(SERVER_URL);
request.addHeader("Content-Type", "application/json; charset=utf-8");
HttpResponse httpResponse = null;
try {
httpResponse = new DefaultHttpClient().execute(request);
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
if (httpResponse.getStatusLine().getStatusCode() !=404){
String result = null;
try {
result = EntityUtils.toString(httpResponse.getEntity());
} catch (ParseException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Log.i("result",result);// System.out.println(result);
//JSONArray resultArray=new JSONObject(result).getJSONArray("d");
//TextView tv=(TextView)findViewById();
//tv.setText(((JSONObject)resultArray.get(0)).getString("UserName").toString());
}
这是从网上复制的代码,调用一个webservice 但是提示404那行错误,新手,不知道哪的问题