Java から JSON データの POST を実行して、JAX-RS をテストしようとしています。
私は Apache Wink 1.0 と Apache Wink RestClient を使用しています。ドキュメントでは、これが POST の実行方法であると書かれています ...
RestClient client = new RestClient();
Resource resource = client.resource("http://services.co");
String response = resource.contentType("text/plain").accept("text/plain").post(String.class, "foo");
...しかし、POST JSON データにどのような変更を加えますか?
私はこれを試しました:
JSONObject json = new JSONObject();
json.put("abc", 123);
RestClient client = new RestClient();
Resource resource = client.resource("http://services.co");
JSONObject response = resource.contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON).post(JSONObject.class, json);
...しかし、私はPOSTで次のエラーで例外を受け取ります:「タイプクラスnet.sf.json.JSONObjectおよびメディアタイプapplication/jsonのライターはありません」。
どんなアイデアや提案も大歓迎です!
ロブ