我正試圖從android調用澤西寧靜的web服務。我的Android代碼是未找到適用於Java類型,類org.json.JSONObject ....和MIME媒體類型,application/json的消息正文閱讀器
客戶端代碼:
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
Webservice的代碼
@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.sun.jersey.api.client.ClientHandlerException:消息正文閱讀器爲Java類型,類org.json.JSONObject ....和MIME媒體類型,application/json未找到。
你的幫助是非常讚賞
可能重複:http://stackoverflow.com/questions/12048804/a-message-body-writer-for- java-type-class-net-sf -json-jsonobject-and-mime-medi –
你能列出附加到你的服務項目的庫文件嗎? – Joshi
@Joshi我已經包括所有球衣1.18 jar文件 – Mahi