Provide an annotation to allow customisation of the elements declared in the 
request & response representation in the auto-generated wadl
-----------------------------------------------------------------------------------------------------------------------------------------

                 Key: CXF-2862
                 URL: https://issues.apache.org/jira/browse/CXF-2862
             Project: CXF
          Issue Type: Improvement
          Components: JAX-RS
    Affects Versions: 2.2.9
            Reporter: Matthew Smith
            Priority: Minor


In using the auto-generated wadl for jax-rs rest services in cxf (2.2.9) I have 
found that all my jaxb annotated xml beans are defined in the grammars section 
of the wadl, but they are not referenced as elements in the representation 
element of methods in the resources section. Indeed it would be difficult to 
automatically determine the correct element for methods that return a Response 
object containing a jaxb annotated object instead of  returning the object 
itself.

To overcome this I suggest creating a WadlElement annotation that allows the 
method to be annotated with the class accepted in the request and returned by 
the response even where it is not the declared return type of the method.

For example, the following method declaration in a Rest service currently 
produces an auto-generated wadl as shown below:

// method from jax-rs service:
        @POST
        @Path("/")
        @Produces("application/xml")
        @Consumes("application/xml")
        public Response doStuff(@Context MessageContext context, MyXmlBean 
bean) {
                return Response.ok(bean, 
MediaType.APPLICATION_XML_TYPE).build();
         }

<!-- snippet of auto-generated wadl: -->
    <resource path="/">
      <method name="POST">
        <request>
          <representation mediaType="application/xml" />
        </request>
        <response>
          <representation mediaType="application/xml" />
        </response>
      </method>

Using the annotation, this would become:

// method from jax-rs service using annotation:
        @POST
        @Path("/")
        @Produces("application/xml")
        @Consumes("application/xml")
        @WadlElement(request = MyXmlBean.class, response = MyXmlBean.class)
        public Response doStuff(@Context MessageContext context, MyXmlBean 
bean) {
                return Response.ok(bean, 
MediaType.APPLICATION_XML_TYPE).build();
         }

<!-- snippet of auto-generated wadl usign annotation. Note that the element 
"order" is defined in the grammars section of the wadl: -->
    <resource path="/">
      <method name="POST">
        <request>
          <representation mediaType="application/xml" element="order" />
        </request>
        <response>
          <representation mediaType="application/xml" element="order" />
        </response>
      </method>


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to