安卓是Java类型的消息体阅读器,类org。json。JSONObject。。。。未找到MIME媒体类型application/json
我正在尝试从安卓调用jersey restful web服务。我的安卓代码是
客户端代码:
HttpClient httpClient = new DefaultHttpClient();
HttpPost post = new HttpPost("http://X.X.X.X:8080/RestfulService/rest/post");
post.setHeader("content-type", "application/json");
JSONObject dato = new JSONObject();
dato.put("email", email);
dato.put("password", password);
StringEntity entity = new StringEntity(dato.toString());
post.setEntity(entity);
HttpResponse resp = httpClient.execute(post);
String rs = EntityUtils.toString(resp.getEntity());
return rs
网络服务代码
@POST
@Produces({ MediaType.APPLICATION_JSON })
@Consumes({ MediaType.APPLICATION_JSON })
public String AuthMySQL(JSONObject json) {
String password = (String) json.get("password");
String email = (String) json.get("email");
*I am using the string values to get the result from the database*
}
我得到的错误类似于com。太阳运动衫应用程序编程接口。客户ClientHandlerException:Java类型的消息体读取器,类org。json。JSONObject。。。。未找到MIME媒体类型application/json
非常感谢你的帮助
共 (0) 个答案