Hi!

I am trying to model rest api  which can consume different xml
representations, but without success
I have two methods on same url which accepts application/xml, but different
objects: single object and collection of objects

<representation mediaType="application/xml" element="cb:point"/>
<representation mediaType="application/xml" element="cb:points"/>

With two methods generated

    @POST
    @Consumes("application/xml")
    @Produces("text/plain")
    String create(Point point);

    @POST
    @Consumes("application/xml")
    @Produces("text/plain")
    String createPoints(Points points);

Becouse resource selection comes before unmarshalling, i am getting warning

12:23:44.215 [http-nio-8080-exec-11] WARN
o.apache.cxf.jaxrs.utils.JAXRSUtils - Both zzz.PointsResourceImpl#create
and zzz.PointsResourceImpl#createPoints are equal candidates for handling
the current request which can lead to unpredictable results

Does it possible or not to have different xml representations on same url
and same media type? May be this is somehow possible with simple
improvements in code, if someone points me to it.
If not, what is preferred way to implement both single and multi-object
resources?

I have options:
1) use only multiple-objects version of resource, but this is not very
elegant, always to have envelope, and many rest guides follows
single-object crud
2) use not-xml envelope, like multipart/form-data (standard, but adding
unecessary envelopes ugly)

Reply via email to