Return-Path: Delivered-To: apmail-cxf-issues-archive@www.apache.org Received: (qmail 56939 invoked from network); 28 Jun 2010 17:17:46 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 28 Jun 2010 17:17:46 -0000 Received: (qmail 25349 invoked by uid 500); 28 Jun 2010 17:17:46 -0000 Delivered-To: apmail-cxf-issues-archive@cxf.apache.org Received: (qmail 25244 invoked by uid 500); 28 Jun 2010 17:17:45 -0000 Mailing-List: contact issues-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list issues@cxf.apache.org Received: (qmail 25236 invoked by uid 99); 28 Jun 2010 17:17:45 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 28 Jun 2010 17:17:45 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED,NORMAL_HTTP_TO_IP X-Spam-Check-By: apache.org Received: from [140.211.11.22] (HELO thor.apache.org) (140.211.11.22) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 28 Jun 2010 17:17:42 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id o5SH9omm020289 for ; Mon, 28 Jun 2010 17:09:50 GMT Message-ID: <15248859.95641277744990453.JavaMail.jira@thor> Date: Mon, 28 Jun 2010 13:09:50 -0400 (EDT) From: "Matthew Smith (JIRA)" To: issues@cxf.apache.org Subject: [jira] Issue Comment Edited: (CXF-2862) Provide an annotation to allow customisation of the elements declared in the request & response representation in the auto-generated wadl In-Reply-To: <25421297.55541277458012016.JavaMail.jira@thor> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/CXF-2862?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12883211#action_12883211 ] Matthew Smith edited comment on CXF-2862 at 6/28/10 1:09 PM: ------------------------------------------------------------- Hi Sergey, Thanks for the response. Setting the useJaxbContextForQnames property of the WadlGenerator to false resulted in an empty grammars element in the wadl, so I removed it again (having also tried it in combination with an @XmlName annotation). Adding a namespace to the @XmlRootElement annotation did result in an element attribute being added to the representation. This is good when the method accepts or returns a jaxb annotated object (thanks), but does't work if the method being described returns a Response object instead of a jaxb annotated object. I have modified the patch so that it takes account of the namespace in @XmlRootElement: Jaxb annotated bean: @XmlRootElement(name = "myBeanName", namespace = "myPrefix") public class MyXmlBean { //... } Annotated service method: @POST @WadlElement(request = MyXmlBean.class, response = MyXmlBean.class) public Response createMyXmlBean(@Context MessageContext context, MyXmlBean bean) { return Response.ok(bean, MediaType.APPLICATION_XML_TYPE).build(); } generated WADL: was (Author: yetanothermatt): Hi Sergey, Thanks for the response. Setting the useJaxbContextForQnames property of the WadlGenerator to false resulted in an empty grammars element in the wadl, so I removed it again (having also tried it in combination with an @XmlName annotation). Adding a namespace to the @XmlRootElement annotation did result in an element attribute being added to the representation. This is good when the method returns a jaxb annotated object (thanks), but won't work if the method being described returns a Response object instead of a jaxb annotated object, and doesn't appear to work for objects in the request body. I (will) have modified the patch so that it takes account of the namespace in @XmlRootElement: Jaxb annotated bean: @XmlRootElement(name = "myBeanName", namespace = "myPrefix") public class MyXmlBean { //... } Annotated service method: @POST @WadlElement(request = MyXmlBean.class, response = MyXmlBean.class) public Response createMyXmlBean(@Context MessageContext context, MyXmlBean bean) { return Response.ok(bean, MediaType.APPLICATION_XML_TYPE).build(); } generated WADL: > 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 > Attachments: WadlElement.patch > > > 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(); > } > > > > > > > > > > > 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(); > } > > > > > > > > > > -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.