You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在WADL关联的XSD中为请求模式新增根元素

WADL关联XSD新增request schema根元素操作方案

操作共分为2个核心步骤:

  • 第一步:在<grammars>标签内补充request schema的根元素定义
    你需要在原有空的<grammars>节点内嵌入XSD片段,声明request对应的根元素(可自行修改根元素名,示例用requisitionRequest作为根元素名),示例代码如下:
<grammars>
  <!-- 原有response的schema定义保留,此处新增request schema -->
  <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
             targetNamespace="http://your.custom.namespace/request" 
             xmlns:tns="http://your.custom.namespace/request"
             elementFormDefault="qualified">
    <!-- 定义request根元素 -->
    <xs:element name="requisitionRequest" type="tns:RequisitionRequestType"/>
    <xs:complexType name="RequisitionRequestType">
      <xs:sequence>
        <!-- 此处按照你的业务需求补充request内部的字段结构 -->
        <xs:element name="realm" type="xs:string" minOccurs="0"/>
        <xs:element name="apiKey" type="xs:string" minOccurs="0"/>
        <xs:element name="filters" type="xs:string" minOccurs="0"/>
        <!-- 其余请求字段按需补充 -->
      </xs:sequence>
    </xs:complexType>
  </xs:schema>
  <!-- 原有response的schema定义保留在此处 -->
</grammars>
  • 第二步:在<request>节点下新增<representation>绑定根元素
    你需要给请求声明绑定刚才定义的根元素,若你的请求是带请求体的POST/PUT等方法,直接添加对应representation即可;如果是示例中的GET方法,可按需保留原有param参数同时绑定根元素:
<request>
  <!-- 原有param参数可按需保留 -->
  <param name="realm" default="aaa" type="xs:string" required="false" style="query" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
  <param name="apiKey" default="aaa" type="xs:string" required="false" style="header" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
  <param name="accept" default="aaa" type="xs:string" required="false" style="header" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
  <param name="Authorization" type="xs:string" required="false" default="aaa" style="header" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
  <param name="filters" type="xs:string" required="false" default="aaa" style="header" xmlns:xs="http://www.w3.org/2001/XMLSchema"/>
  <!-- 新增request根元素绑定,注意namespace前缀要和你定义的schema对应 -->
  <representation mediaType="application/json; charset=utf-8" element="tns:requisitionRequest" xmlns:tns="http://your.custom.namespace/request"/>
</request>

注意:如果你不需要保留原有松散的param定义,可以直接删除param节点,全部字段收敛到根元素结构中即可。

内容的提问来源于stack exchange,提问作者Nikhil Bagde

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.04 22:36:04