を使用してアンドロイドのデータを転記することはできません、私が実行しようとしていますが、私はFatalErrorExceptionを取得していますが、私は、ブラウザには、以下のWebサービス
http://localhost:8082/WebServices/Rest/courseService/LoginInfo/a:a
にURLを使用してWebサービスのコードを実行しようとすると、それは完璧に動作し、完璧与えコードsnipetsですその結果、私は、コードの下に使用してアンドロイドと同じことを行うことはできません
私は
public class ServiceHandler {
static String response = null;
public final static int GET = 1;
public final static int POST = 2;
// Default Constructor
public ServiceHandler() {
// TODO Auto-generated constructor stub
}
public String makeServiceCall(String url, int method) {
return this.makeServiceCall(url, method, null);
}
public String makeServiceCall(String url, int method, String parameter) {
try {
// http client
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpEntity httpEntity = null;
HttpResponse httpResponse = null;
// Checking http request method type
if (method == POST) {
HttpPost httpPost = new HttpPost(url);
httpResponse = httpClient.execute(httpPost);
} else if (method == GET) {
// appending params to url
if (parameter != null) {
url += parameter;
}
HttpGet httpGet = new HttpGet(url);
httpResponse = httpClient.execute(httpGet);
Log.d("Parmaeter2",parameter);
}
httpEntity = httpResponse.getEntity();
response = EntityUtils.toString(httpEntity);
} catch (Exception e){
Log.d("Service Handler Error",e.toString());
}
return response;
}
}
は、しかし、私は、すべてのWebサービス要求を処理するこのServiceHandlerClassを持っていますエラー
04-10 03:30:44.850: E/AndroidRuntime(5559): Caused by: java.lang.NoSuchMethodError: org.apache.http.impl.client.DefaultHttpClient.execute
04-10 03:30:44.850: E/AndroidRuntime(5559): at com.example.shoponchat.ServiceHandler.makeServiceCall(ServiceHandler.java:52)