Hi
I am new to Seam and want to develop Webservice using Seam.I have an aggressive deadline Where i can find the details to develop the Webservice using Seam.Any good document, book, website etc.
Hi
I am new to Seam and want to develop Webservice using Seam.I have an aggressive deadline Where i can find the details to develop the Webservice using Seam.Any good document, book, website etc.
As mentioned in the other question you could use JAX-WS. However if you'd rather use REST services (JAX-RS) then either:
EDIT: Norman Richards from the Seam team has just posted a blog article about Seam and JAX-RS. Looks fantastic and probably more what you are after than Jersey.
I had a look at Jersey last week and was amazed at how little code you need. Here's a little guide:
url-pattern
of service/*
)Here's an example of a Service:
@Path("/users")
public class UsersService {
@GET
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
public Users getUsers() {
return UserQuery.getUsers();
}
}
Where this is the Users class:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "users")
public class Users {
@XmlElement(name="users")
private List<User> users = new ArrayList<User>();
public List<User> getUsers() {
return this.users;
}
public void setUsers(List<User> users) {
this.users = users;
}
}
And this is the User class:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "user")
public class User implements Serializable {
@XmlElement(name="id")
private long userId;
@XmlElement(name="firstName")
private String firstName;
@XmlElement(name="lastName")
private String lastName;
@XmlElement(name="email")
private String email;
public User() {}
public User(long userId, String firstName, String lastName, String email) {
this.userId = userId;
this.firstName = firstName;
this.lastName = lastName;
this.email = email;
}
//And the getter/setters
}
Then you can access the service at http://yourhost/service/users It will produce XML or JSON depending on what your client has for it's HTTP Accepts header. Pretty cool huh?