tags:

views:

31

answers:

1

I want to make a Post to Jersey Rest service. What is the standard way of doing this?

@Post @Consumes(MediaType.Application_xml) public Response method(??){}

A: 

Below is an example of a post operation:

@POST
@Consumes({"application/xml", "application/json"})
public Response create(@Context UriInfo uriInfo, Customer entity) {
    entityManager.persist(entity);
    entityManager.flush();

    UriBuilder uriBuilder = uriBuiler.path(String.valueOf(entity.getId()));
    return Response.created(uriBuilder.build()).build();
}
Blaise Doughan