将json发送到另一个URL

时间:2016-04-07 10:01:01

标签: java json web-services url servlets

我尝试将一些json值从我的servlet类发送到另一个在不同系统中运行的应用程序。这是我的servlet类

   @WebServlet("/bootHttp")
public class BootServlet extends HttpServlet {

    @Override
    protected void doPut(HttpServletRequest request,
            HttpServletResponse response) throws ServletException, IOException 
    {

        String boot_request = request.getParameter("request_boot");
        System.out.println("boot_request = " + boot_request);
        // String start_request = request.getParameter("request_start");
        String json=" **{\n" +
          "\"cmschangeavailability\":\n" +
          "{\n" +
          " \"cmschangeavailabilitycpid\":\"1\",\n" +
          " \"cmschangeavailabilityconnectorid\":\"1\",\n" +
          " \"cmschangeavailabilitytype\":\"InOperative\"\n" +
          "}\n" +
          "}";**   

    }
} 

我想发送上面的json String(我也可以使用JSONObject构建json,如果需要)到“www.devsitexxx.xom / abcd / changeavailability”URL我可以使用REST webservices来执行下面的操作

@PUT
@Path("changeavailability")
@Produces({"application/json"})
@Consumes("application/json")
public jsonFormat cmsChangeAvailability(MainCMSChangeAvailabilityPOJO 
cmsChangeAvailability) throws JSONException, IOException {
}

0 个答案:

没有答案