[ https://issues.apache.org/jira/browse/CXF-7825?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16610453#comment-16610453 ]
Andrei Ivanov commented on CXF-7825: ------------------------------------ I'm still not sure about the problem you mention as my code seems to work fine. The same generated interface is used for both server endpoints and for the client runtime proxies, which seem to use the 1st media type defined in the {{@Produces}} annotation. Maybe it's something specific to CXF? I forgot to mention that we use Jersey for the JAX-RS runtime. > wadl2java: support multiple representations of the same element > --------------------------------------------------------------- > > Key: CXF-7825 > URL: https://issues.apache.org/jira/browse/CXF-7825 > Project: CXF > Issue Type: Bug > Components: JAX-RS, Tooling > Affects Versions: 3.2.6 > Reporter: Andrei Ivanov > Priority: Major > > 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): > {code: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> > {code} > 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: > {code:xml} > <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> > {code} > {code:java} > @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); > } > {code} > 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. -- This message was sent by Atlassian JIRA (v7.6.3#76005)