【问题标题】:Missing method id attribute in generated WADL with ServiceMix 7 M3 and CXF使用 ServiceMix 7 M3 和 CXF 生成的 WADL 中缺少方法 ID 属性
【发布时间】:2017-12-13 06:24:10
【问题描述】:

我们正在使用 ServiceMix 7.0.0.M3 并使用 CXF WADL 生成器。 现在生成的 WADL 似乎在 resource>method 标记中没有“id”属性。例如,以下 WADL 中的第 4 行没有“id”属性。

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

如果我要使用 Jersey 生成 WADL,我将获得一个“id”属性,其中包含相应 Java 方法的名称。

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

我们的一个前端开发工具要求存在“id”属性。

是否可以将 CXF WADL 生成器配置为包含方法 id 属性?

【问题讨论】:

    标签: cxf wadl apache-servicemix


    【解决方案1】:

    我找到了。将 WadlGenerator 配置属性“addResourceAndMethodIds”添加到 CXF 蓝图文件时会生成 ID:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-15
      • 2018-03-09
      • 1970-01-01
      相关资源
      最近更新 更多