Question

I have below RestFul web service method devleoped using Jersey.

@GET
@Produces ("application/xml")
public User validateAndReturn(User  user) {
User als=null;
try {
als= UserService.validate(user);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return als;
}

Here User.java class is not generated from xsd and is handwritten. In this case how clients would call my web service? Do they need User.java and populate it through setters and getters?

Thanks!

Was it helpful?

Solution

You need to share User object details with your client. Choice is yours, in which way you do.

XML schema representation is used because that is language independent. It allows clients written in different technology to create their own input object confirming to the schema. Almost all the languages provide libraries to generate classes from xml these days.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top