-2
我正在使用Tom Cat服务器和Jersey Framework来实现RESTful Web服务。我有一个主要方法,我想在main中调用它,然后运行Tomcat。我怎样才能做到这一点?从主要方法调用java应用程序中的Web服务
@GET
@Path("/{parameterPk}/{parameterData}")
public Response getJSONObj(@PathParam("parameterPk") String parameterPk,
@PathParam("parameterData") String parameterData) {
System.out.println("Starting...");
JSONObject jsonObj = new JSONObject();
jsonObj.put(IDENTIFIER_JSON_ID, parameterPk);
jsonObj.put(IDENTIFIER_JSON_DATA, parameterData);
JSONArray jsonarray = new JSONArray();
jsonarray.add(jsonObj);
System.out.println(jsonarray);
JSONObject jsonMain = new JSONObject();
jsonMain.put("Employee", jsonarray);
System.out.println(jsonMain.toString());
return Response.status(200).entity(jsonMain.toString()).build();
}
你有服务运行和测试?据我了解 - 你想创建一个客户端?我相信你会失去在搜索引擎中搜索“java restful client”的例子(例如https://alvinalexander.com/java/java-apache-httpclient-restful-client-examples) – gusto2