Passing an object to a REST Web Service using Jersey

前端 未结 5 740
无人共我
无人共我 2020-12-17 04:04

I have a simple WS that is a @PUT and takes in an object

@Path(\"test\")
public class Test {

    @PUT
    @Path(\"{nid}\"}
    @Consumes(\"appl         


        
5条回答
  •  既然无缘
    2020-12-17 04:38

    You can try something like this

    @POST
    @Path("/post")
    @Consumes(MediaType.APPLICATION_XML)
    @Produces(MediaType.APPLICATION_XML)
    public Response callWol(WolRequest nid) {
         WolResponse response = new WolResponse();
         response.setResult(result);
         response.setMessage(nid.getValue().getId());
         return Response.status(Status.OK).entity(response).build();
    }
    

    You can try @PUT instead of @Post as well. Hope this helps

提交回复
热议问题