ちょっと残っているjsonオブジェクトを残りのWebサービスに送信してから、特定のキーの値を取得してから、別の場所で使用される新しいjsonオブジェクトを返します。とにかく、私はサービスと通信しようとするとHTTP 204を取得しています。JsonObjectは、jsonObjectを送信しようとしているときにPOSTメソッドでHTTP 204を返します。
私の残りのサービスは、この
@Path("/example")
public class PdfMaker {
@POST
@Path("/post")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response PruebasMet(JSONObject json) throws IOException, JSONException{
try{
String xml = json.getString("xml");
String plantilla = json.getString("plant");
//method that uses "xml" and "plant" and returns "pdf"
JSONObject response = new JSONObject();
response.put("pdf", pdf);
return Response.status(200).entity(pdfb64.toString()).build();
}catch(Exception e){
e.getStackTrace();
return null;
}
}
のように見えると私は、この
public class Jersey {
public static String baseuri = "http://localhost:8080/PdfMakerGF/rest/example/post";
public static void main(String[] args) {
try {
ClientConfig config = new DefaultClientConfig();
Client client = Client.create(config);
WebResource webResource = client.resource(baseuri);
JSONObject objTest = new JSONobject();
objTest.put("xml","Data1");
objTest.put("plan", "Data2");
ClientResponse res = webResource.header("Content-Type","application/json;charset=UTF-8")
.post(ClientResponse.class, objTest.toString());
System.out.println("output..." + "\n");
System.out.println("Answer "+res);
} catch (Exception e) {
e.printStackTrace();
}
}
と通信しようとしている。しかし、私が受け取ることに応答がこの1件の
回答POSTでありますhttp://localhost:8080/PdfMakerGF/rest/example/post は204の応答ステータスを返しました。
明らかに何か間違っていますが、それが何であるかはわかりません。 私はこれに固執しています。どんな種類の助けにも感謝します。 私はnetbeans 8.1、Glassfish 4.1、Jerseyを使用しています。 ありがとう
Aを提供しているという情報を持っていますlsoサービスはxml形式で証明され、正常に動作します –
サーバーログで例外をチェックしましたか? – sisyphus
郵便配達員で同じリクエストを送信しようとしましたか? – ngc4151