cxfwadlapache-servicemix

Missing method id attribute in generated WADL with ServiceMix 7 M3 and CXF


We are using ServiceMix 7.0.0.M3 and use the CXF WADL generator. Now the generated WADL does not seem to have a 'id' attribute in the resource>method tags. For example, the 4th line in the following WADL does not have an 'id' attribute.

<resources base="http://localhost:8181/api/rest/box">
   <resource path="/">
      <resource path="boxes">
         <method name="GET">
            <request>
               <param name="language" style="header" type="xs:string"/>
               <param name="includeInactive" style="query" type="xs:boolean"/>
            </request>
            <response>
               <representation mediaType="application/json;charset=utf-8" element="prefix1:BoxRestResponse"/>
            </response>
         </method>
      </resource>

If I would have the WADL generated with Jersey, I would get an 'id' property, containing the name of the corresponding Java method.

<resources base="http://localhost:8181/api/rest/box">
   <resource path="/">
      <resource path="boxes">
         <method name="GET" id="getBoxes">
            <request>
               <param name="language" style="header" type="xs:string"/>
               <param name="includeInactive" style="query" type="xs:boolean"/>
            </request>
            <response>
               <representation mediaType="application/json;charset=utf-8" element="prefix1:BoxRestResponse"/>
            </response>
         </method>
      </resource>

One of our frontend development tools expects the 'id' attribute to be present.

Is it possible to configure the CXF WADL generator to include the method id attribute?


Solution

  • I found it. The id's are generated when adding the WadlGenerator configuration property 'addResourceAndMethodIds' to the CXF Blueprint file:

       <bean id="wadlGenerator" class="org.apache.cxf.jaxrs.model.wadl.WadlGenerator">
            <!-- properties: Method Summaries @ https://cxf.apache.org/javadoc/latest/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.html -->
            <property name="linkJsonToXmlSchema" value="true" />
            <property name="useJaxbContextForQnames" value="true" />
            <property name="addResourceAndMethodIds" value="true" />
        </bean>