Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/230.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android HttpURLConnection Delete不';我不能在安卓系统中工作_Android_Httpurlconnection - Fatal编程技术网

Android HttpURLConnection Delete不';我不能在安卓系统中工作

Android HttpURLConnection Delete不';我不能在安卓系统中工作,android,httpurlconnection,Android,Httpurlconnection,我想从Android中的RESTful Web服务中删除一个项目。我的Web服务如下所示: @DELETE @Path("/schueler/{id}") @Produces(MediaType.APPLICATION_JSON) public void deleteSchueler(@PathParam("id") int id) { ManagementDAO.instance.deleteSchueler(id); } 下面是一些Android代码。首先调用异步任务: new A

我想从Android中的RESTful Web服务中删除一个项目。我的Web服务如下所示:

@DELETE
@Path("/schueler/{id}")
@Produces(MediaType.APPLICATION_JSON)
public void deleteSchueler(@PathParam("id") int id) {
    ManagementDAO.instance.deleteSchueler(id);
}
下面是一些Android代码。首先调用
异步任务

new AsyncDeleteSchueler(getApplicationContext()).execute("http://" + url.getText().toString() + ":8080/A07_Webservice/rest/ManagementService/schueler/" + Integer.parseInt(deleteId.getText().toString()));
以及此任务的代码:

public String putJSONToWebservice(String u) {
    int responseCode = 0;

    try {
        URL url = new URL(u);
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();

        connection.setRequestMethod("DELETE");
        connection.setDoOutput(true);
        connection.setReadTimeout(10000);
        connection.setConnectTimeout(15000);
        connection.setRequestProperty("Content-Type", "application/json");
        connection.setRequestProperty("Accept", "application/json");

        connection.connect();
        responseCode = connection.getResponseCode();
    } catch(Exception ex) {
        ex.printStackTrace();
    }

    return Integer.toString(responseCode);
}

你知道为什么
Delete方法不起作用吗?PUT、POST等工作正常,但此代码不起作用。

我认为删除是通过POST请求处理的。你有你使用的API的文档吗?API的错误响应是什么?日志中应该有错误