I’ve just learned how to send a single complex object to a Jersey-based REST web service by means of JAXB mapping: http://jersey.java.net/nonav/documentation/latest/xml.html#d4e820
However, I’d like to do a bit more.
1) Can I have a method that accepts multiple complex objects, all annotated with JAXB? I mean something like:
@POST
public void setPlanetAndGalaxy ( Planet planet, Galaxy galaxy ) { ... }
Does Jersey allow for such a method? How would a client counter-part look like, using Jersey/Client? So far I’ve got the impression that I should define a wrapper like class GalaxyPlanet { planet, galaxy }, I don’t like that very much.
2) Is it possible to have an array or a collection parameter for a POST method? Like in:
@POST
public void setPlanets ( Planet ... planets ) {...}
@POST
public void setPlanets ( Set<Planet> planets ) {...}
@POST
public void setPlanetsAndGalaxies ( Set<Planet> planets, Set<Galaxy> galaxies )
How would the client code look like in these three different cases?
Thanks in advance for any help.
Marco.
You should identify your resources and their relationships first. If you are going to deal with only galaxies and planets (for example) your REST API paths would be something like
You would be able to deal with
Listas POST method parameter.public void setPlanets ( List<Planet> planets ) {...}Accepting multiple complex type parameters may not be possible.