web-services - 使用 WADL 记录 POST 参数

标签 web-services documentation wadl

看着 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> 的 child , the spec describes it as :

Specifies a URI query parameter represented according to the rules for the query component media type specified by the queryType attribute.



“URI 查询”位让我失望,因为对我来说,它建议将参数附加到 URI 而不是包含在正文中。

另一方面,对于 <param style="query">用作 <representation> 的 child ,规范有:

Specifies a component of the representation as a name value pair formatted according to the rules of the media type. Typically used with media type 'application/x-www-form-urlencoded' or 'multipart/form-data'.



我是否必须使用 <representation>元素来明确记录将作为 POST 正文的一部分以编码方式发送的参数?
<resource path="/path1">
    <method name="POST">
        <request>
            <representation mediaType="application/x-www-form-urlencoded">
                <name="param1" style="query"/>
            </representation>
        </request>
    </method>
</resource>

这看起来有点矫枉过正。我假设我应该能够使用前者,即使规范提到了“URI 查询”。

最佳答案

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

第三方编辑

后一个可能意味着这个

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

关于web-services - 使用 WADL 记录 POST 参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2877426/

相关文章:

http - 在 WADL 中定义 HTTP 基本身份验证 header 的最具描述性的方法是什么?

java - 如何从 POJO 自动生成 JAXB 注释?

c# - 在 .net webservice 中使用 FormsAuthentication 进行安全登录,还是这样?

php - PHPdoc @param 中的两种或多种数据类型

list - 是否有已知的网络爬虫列表?

java - 在 Jersey 中,如何指定仅显示资源的最小 application.wadl?

rest - GraphQL 比 REST 好在哪里?

web-services - CORS 实际上如何防止安全问题?

c# - 如何在 C# 父类/接口(interface)和子类之间同步 XML 注释