Description
Hi,
I have little experience using WADL and I'm trying to define a resource which accepts a request parameter with multiple representations (JSON and XML):
<resource id="PaymentManagementService" path="/paymentmanagement"> <resource path="/transaction/{uuid}"> <doc>Store a Payment corresponding to the specified transaction</doc> <param name="uuid" style="template" type="ns:uuid" /> <method id="storePayment" name="PUT"> <request> <representation mediaType="application/json" element="ns:Payment" /> <representation mediaType="application/xml" element="ns:Payment" /> </request> <response status="200" > <doc>Returns the newly stored payment</doc> <representation mediaType="application/json" element="ns:Payment" /> <representation mediaType="application/xml" element="ns:Payment" /> </response> <response status="500" > <doc>Storing of the payment failed</doc> <representation mediaType="application/json" element="ns:ExceptionDetails" /> <representation mediaType="application/xml" element="ns:ExceptionDetails" /> </response> </method> </resource> </resource>
As far as I see, after CXF-3797, the generator doesn't handle this scenario, considering them as different types.
I've also tried this way, which I'm not even sure is correct, but the generator seems to generate correct code, which is a single method which consumes the 2 media types:
<representation mediaType="application/json"> <param name="payment" style="query" type="ns:Payment" /> </representation> <representation mediaType="application/xml"> <param name="payment" style="query" type="ns:Payment" /> </representation>
@Path("/paymentmanagement") public interface PaymentManagementService { /** * @return Returns the newly stored payment */ @PUT @Consumes({"application/json", "application/xml" }) @Produces({"application/json", "application/xml" }) @Path("/transaction/{uuid}") Payment storePayment(@PathParam("uuid") String uuid, Payment payment); }
The problem with this approach is that now I'm trying to enable bean validation, but the generator ignores this 2nd approach representations because it doesn't find an element attribute on the representations.
Not sure what the solution is, maybe just update the generator to handle the 1st approach properly.