RESTful Services
XML Support
1/10
1
Read Answer
Write Jersey client to test the resource:
public class Exam {
public int id;
public String name;
}
@Path("exam")
public class ExamService {
@POST
@Consumes(MediaType.APPLICATION_XML)
public void setExam(JAXBElement<Exam> exam) {
System.out.println("setExam " + exam.getValue().name);
System.out.println("setExam " + exam.getValue().id);
}
}Client client = Client.create();
WebResource resource = client.resource(".../exam");
// POST
Exam exam = new Exam();
exam.id = 1;
exam.name = "OCJP 6";
resource.post(new JAXBElement<Exam>(new QName("exam"), Exam.class, exam));
Please log in or register to have a possibility to add comment.