【问题标题】:Understanding WADL specification - document required post parameter了解 WADL 规范 - 记录所需的 post 参数
【发布时间】:2015-07-28 09:39:25
【问题描述】:

关于WADL-specification,我有两个问题。

他们的示例http://foo.it/widgets/123?custId=cust1234&verbose=true 包含两个可选的查询参数custIdverbose

  1. 他们的示例中给定的节点结构是否正确?
  2. 您能否给出或更正我的带有强制参数的后请求示例?
  3. header 是什么意思,我必须在哪里放置 xml - 我的理解正确吗?

引用自 2.8.1 查询参数

资源或请求的子参数元素(参见第 2.12 节) “query”的样式值表示所描述的 URI 查询参数 在 HTML 4.01[4] 的第 17.13 节中。查询的运行时值 当 HTTP 方法是,参数作为 URI 查询参数发送 调用。

以下示例显示了具有生成 URI 的资源 支持带有两个可选查询的单个 HTTP 方法 参数

这是他们的例子

<resources base="http://example.com/widgets">
    <resource path="{widgetId}">
        <param name="custId" style="query"/>
        <method name="GET">
            <request>
                <param name="verbose" style="query" type="xsd:boolean"/>
            </request>
            <response>
            ...
            </response>
        </method>
    </resource>
</resources>

在我看来resource param method request param的顺序或者层次不正确

  resource 
  ++ param      <-- why is this here
  ++ method
  ++++ request
  ++++++ param    <-- and the other one here
  ++++ /request

问题一:参数在节点内的位置

我本来希望参数都在&lt;request&gt;里面,就像这里

<resource path="{widgetId}"> 
   // removed custId
    <method name="GET">
       <request>
           <param name="custId" style="query"/>
           <param name="verbose" style="query" type="xsd:boolean"/>
        </request>
        ....
    </method>
</resource>

所以这个层次结构

  resource 
  ++ method
  ++++ request
  ++++++ param      <-- all params are inside request
  ++++++ param    
  ++++ /request

我的理解是正确的,应该如何嵌套参数还是无关紧要还是有不同的含义?

问题 2:您如何记录所需的 post 参数

这个 sn-p 正确吗?

<method name="POST">
  <request>
    <param name="custId" style="query" required="true"/>
    <param name="verbose" style="query" required="true" type="xsd:boolean"/>
  </request>
  ....
</method>

更新第三季度。 header的使用和理解

我要怎么理解:header:指定一个HTTP header,用于资源类型的所有子方法元素的请求部分

这会像下面的示例一样,并且字段 userId 将是每个请求中 http-header 的一部分吗?

  <request>
    <param name="userId" style="header" required="true" />
    ....
 </request>

谢谢

第一个部分答案

至少基于wikipedia entry to WADL 所需的部分似乎是正确的

<method name="GET" id="search"> 
 <request> 
  <param name="appid" type="xsd:string" style="query" required="true"/> 
  <param name="query" type="xsd:string" style="query" required="true"/> 
 ...

【问题讨论】:

    标签: web-services rest wadl


    【解决方案1】:

    当您使用 WSDL 或 SOAP 消息传递时,您定义了这些称为部件的元素(输入、输出操作)。这些部分使用称为模式的定义部分。

    这个模式元素要么是 WSDL 的一部分,要么是一个单独的 XSD 文档。而这个架构元素就是告诉格式和规则的东西。

    第一季度。格式好像不对,参考这个例子https://docs.oracle.com/cd/E41633_01/pt853pbh1/eng/pt/tibr/concept_UnderstandingWADLDocuments-7b7fd7.html

    第二季度。发布请求示例

    <method id="POSTWeatherStation.v1" name="POST">
        <request>
          <resource path="weather/{state}/{city}?forecast={day}">
            <param name="state" required="true" style="template" type="xsd:string"/>
            <param name="city" required="true" style="template" type="xsd:string"/>
            <param name="day" required="true" style="template" type="xsd:string"/>
          </resource>
    

    第三季度。是的,它应该是将参数指定为标头的方法的一部分。

    【讨论】:

    • 感谢您的回复。你能解决我的任何问题吗?
    • 你能把你的 WSDL 文件和 XSD 粘贴到这里吗
    • 我没有 WSDL 也没有 XSD。我想了解 WADL 规范。
    猜你喜欢
    • 1970-01-01
    • 2015-11-25
    • 2011-08-22
    • 1970-01-01
    • 2016-07-11
    • 2019-08-24
    • 2019-03-26
    • 2011-01-31
    • 2016-11-25
    相关资源
    最近更新 更多