[ 
https://issues.apache.org/jira/browse/CXF-7825?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16610327#comment-16610327
 ] 

Andrei Ivanov commented on CXF-7825:
------------------------------------

Hmm, my problem is with the request, not with the response, as those 
definitions are accepted fine by the generator.

> 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)

Reply via email to