gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 15:37:43 25 4
gpt4 key购买 nike

看着 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com