@Test public void testSaveEmployee(){ Department department = new Department(1,"研发部"); Employee employee = new Employee(1,"scott",department); JAXBElement<Employee> element = new JAXBElement<Employee>(new QName("employee"), Employee.class, employee); Response response = target("employee").request().post(Entity.entity(element,MediaType.APPLICATION_XML)); System.out.println(response.getStatus()); System.out.println(response.readEntity(String.class)); }
@POST public JAXBElement<Employee> saveEmployee(JAXBElement<Employee> employee){ return employee; }
EmployeeRestService { @POST public JAXBElement<Employee> saveEmployee(JAXBElement<Employee> employee){ return employee; } }
EmployeeRestService { @POST public JAXBElement<Employee> saveEmployee(JAXBElement<Employee> employee){ return employee; }  }
EmployeeRestService { @POST public JAXBElement<Employee> saveEmployee(JAXBElement<Employee> employee){ return employee; }  @Path("/v1") @GET List<JAXBElement<Employee>> getEmployees(); @Path("{id}") @GET JAXBElement<Employee> getEmployee(@PathParam("id")int id); @POST JAXBElement<Employee> saveEmployee(JAXBElement<Employee> employee); @PUT JAXBElement<Employee> updateEmployee(JAXBElement<Employee> employee); @DELETE @Path("{id}") JAXBElement<Employee> deleteEmployee(@PathParam("id")int id); }
EmployeeRestService { @POST public JAXBElement<Employee> saveEmployee(JAXBElement<Employee> employee){ return employee; }  @Path("/v1") @GET List<JAXBElement<Employee>> getEmployees(); @Path("{id}") @GET JAXBElement<Employee> getEmployee(@PathParam("id")int id); @POST JAXBElement<Employee> saveEmployee(JAXBElement<Employee> employee); @PUT JAXBElement<Employee> updateEmployee(JAXBElement<Employee> employee); @DELETE @Path("{id}") JAXBElement<Employee> deleteEmployee(@PathParam("id")int id);  }