代码之家  ›  专栏  ›  技术社区  ›  Ates Goral

用WADL记录柱参数

  •  5
  • Ates Goral  · 技术社区  · 16 年前

    看着 the current version of the WADL proposal ,我不太明白如何记录Post请求参数(使用 application/x-www-form-urlencoded 编码)。

    我在野外见过这样的东西:

    <resource path="/path1">
    <!-- default is mediaType="application/x-www-form-urlencoded" -->
        <method name="POST">
            <request>
                <name="param1" style="query"/>
            </request>
        </method>
    </resource>
    

    然而,对于 <param style="query"> 用作 <request> , the spec describes it as :

    指定一个 URI查询 参数 根据规则代表 查询组件媒体类型 由querytype属性指定。

    “uri query”位让我很不高兴,因为对我来说,它建议将参数附加到uri,而不是包含在主体中。

    另一方面,对于 <param style=“查询”> 用作 <representation> ,规格有:

    指定的组件 表示为名称-值对 按照以下规则格式化 媒体类型。通常用于 媒体类型 'application/x-www-form-urlencoded'或 “多部分/表单数据”。

    我必须使用 <代表性> 元素来显式地记录将以编码方式作为日志正文的一部分发送的参数?

    <resource path="/path1">
        <method name="POST">
            <request>
                <representation mediaType="application/x-www-form-urlencoded">
                    <name="param1" style="query"/>
                </representation>
            </request>
        </method>
    </resource>
    

    这看起来太过分了。我假设我应该能够使用前者,即使规范提到了“uri查询”。

    1 回复  |  直到 11 年前
        1
  •  2
  •   surfmuggle    11 年前

    现在我看到我实际上应该使用后一种形式。即使简单地记录一些post参数看起来有点过分了,最好显式地记录参数是body==表示的一部分这一事实。

    第三方编辑

    后一个可能是指这个

    <resource path="/path1">
        <method name="POST">
            <request>
                <representation mediaType="application/x-www-form-urlencoded">
                    <name="param1" style="query"/>
                </representation>
            </request>
        </method>
    </resource>
    
    推荐文章