Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-6137

WADL generation does not correctly support query parameters

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0.2
    • 3.0.4, 2.7.15, 3.1
    • JAX-RS, Tooling
    • None
    • Windows/Linux; Red Hat JBoss EAP 6.2.2; Java 7u40

    • Moderate

    Description

      I have created a REST API that takes a bean as its only parameter, and specifies the GET method. This converts the bean fields to query parameters. Two of the bean fields are java.util.Date instances.

      When the WADL is generated for this service, the Date objects are rendered as beans instead of xs:dateTime instances, which means our clients cannot use the WADL for code generation.

      As far as we can tell, this issue has the same root cause as CXF-5988; it appears that the WadlGenerator.doWriteBeanParam(...) method on line 807 needs to have the same fix applied where java.util.Date is treated as a special case.

      API definition
          @GET
          @Path("/")
          @WebMethod(action = "get")
          @WebResult(name = "getResponse")
          GetResponse get(@QueryParam("") @WebParam(name = "getRequest") GetRequest request)
      
      Bean definition
      @XmlRootElement(namespace = ...)
      @XmlType(namespace = ...)
      public class GetRequest {
      
          /**
           * Serial version UID.
           */
          private static final long serialVersionUID = 1L;
      
          /**
           * Optional end date defining the lower boundary for the date range within which the entries are searched.
           */
          @Past
          @XmlSchemaType(name = "dateTime")
          private Date endDate;
      
          /**
           * Required start date defining the lower boundary for the date range within which the entries are searched.
           */
          @NotNull
          @Past
          @XmlElement(required = true)
          @XmlSchemaType(name = "dateTime")
          private Date startDate;
      
          /**
           * Retrieves the value for {@link #endDate}.
           * 
           * @return the current value
           */
          public Date getEndDate() {
              return this.endDate;
          }
      
          /**
           * Retrieves the value for {@link #startDate}.
           * 
           * @return the current value
           */
          public Date getStartDate() {
              return this.startDate;
          }
      
          /**
           * Provides a value for {@link #endDate}.
           * 
           * @param endDate the new value to set
           */
          public void setEndDate(Date endDate) {
              this.endDate = endDate;
          }
      
          /**
           * Provides a value for {@link #startDate}.
           * 
           * @param startDate the new value to set
           */
          public void setStartDate(Date startDate) {
              this.startDate = startDate;
          }
      }
      
      Current WADL content
      <method name="GET" id="get">
          <request>
              <param name="applicationId.name" style="query" type="xs:string"/>
              <param name="applicationId.version" style="query" type="xs:string"/>
              <param name="startDate.date" style="query" type="xs:int"/>
              <param name="startDate.hours" style="query" type="xs:int"/>
              <param name="startDate.minutes" style="query" type="xs:int"/>
              <param name="startDate.month" style="query" type="xs:int"/>
              <param name="startDate.seconds" style="query" type="xs:int"/>
              <param name="startDate.time" style="query" type="xs:long"/>
              <param name="startDate.year" style="query" type="xs:int"/>
              <param name="startDate.day" style="query" type="xs:int"/>
              <param name="startDate.timezoneOffset" style="query" type="xs:int"/>
              <param name="groupByType" style="query" type="xs:string">
                  <option value="DAY"/>
                  <option value="MONTH"/>
              </param>
              <param name="pageNumber" style="query" type="xs:int"/>
              <param name="pageSize" style="query" type="xs:int"/>
          </request>
          <response>
              <representation mediaType="application/json" element="api1:getApplicationUsageResponse"/>
          </response>
      </method>
      
      Expected WADL content
      <method name="GET" id="get">
        <request>
          <param name="applicationId.version" style="query" type="xs:string"/>
          <param name="applicationId.name" style="query" type="xs:string"/>
          <param name="groupByType" style="query" type="xs:string">...</param>
          <param name="startDate" style="query" required="true" type="xs:datetime"/>
          <param name="pageNumber" style="query" type="xs:int"/>
          <param name="pageSize" style="query" type="xs:int"/>
        </request>
        <response>
          <representation mediaType="application/json" element="api1:getApplicationUsageResponse"/>
        </response>
      </method>
      

      Attachments

        Issue Links

          Activity

            People

              sergey_beryozkin Sergey Beryozkin
              ms185252 Michael Schechter
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: