尝试向XSD文件添加额外元素

时间:2011-02-08 09:41:27

标签: xml wsdl xsd

我有一个包含以下内容的XSD文件......

    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" id="OTA2003A" targetNamespace="http://www.opentravel.org/OTA/2003/05" version="1.000" xmlns="http://www.opentravel.org/OTA/2003/05">

  <xs:element name="OTA_VehAvailRateRQ">
    <xs:annotation>
      <xs:documentation>The root tag of OTA_VehAvailRateRQ contains standard payload attributes found in all OTA payload documents. Because the results of the search message could be quite numerous, the request also has an attribute, MaxResponses, indicating the number of replies requested.  The attribute  ReqRespVersion is a positive integer value that indicates the version number requested for the response message.</xs:documentation>
    </xs:annotation>
    <xs:complexType>
      <xs:sequence>
        <xs:element name="POS" type="POS_Type">
          <xs:annotation>
            <xs:documentation>Point of Sale Identification.  Identification number of the vendor that has made the vehicle availability request and agency number assigned by IATA, ARC, ESRP or TID.</xs:documentation>
          </xs:annotation>
        </xs:element>
        <xs:element name="VehAvailRQCore" type="VehicleAvailRQCoreType">
          <xs:annotation>
            <xs:documentation>Identifies the common, or core, information associated with the request for availability of a rental vehicle.</xs:documentation>
          </xs:annotation>
        </xs:element>
        <xs:element minOccurs="0" name="VehAvailRQInfo" type="VehicleAvailRQAdditionalInfoType">
          <xs:annotation>
            <xs:documentation>Identifies the supplemental information associated with the request for availability of a rental vehicle.</xs:documentation>
          </xs:annotation>
        </xs:element>
      </xs:sequence>
      <xs:attributeGroup ref="OTA_PayloadStdAttributes"/>
      <xs:attributeGroup ref="ReqRespVersion"/>
      <xs:attributeGroup ref="MaxResponsesGroup"/>
    </xs:complexType>
  </xs:element>

然后我在WSDL文件中引用它。当我通过SoapUI之类的东西运行WSDL文件时,我得到以下输出作为soap请求...

<soap:Body>
    <OTA_VehAvailRateRQ EchoToken="XXX1234" Version="1.0" ReqRespVersion="medium" MaxResponses="16" xmlns="http://www.opentravel.org/OTA/2003/05">      
        ...
        ...
        ...
    </OTA_VehAvailRateRQ>
</soap:Body>

......到目前为止,非常好。现在我需要向XSD文件添加一个元素,以便它将产生以下输出......

<soap:Body>
    <ns:Request xmlns:ns="http://someurl">
        <OTA_VehAvailRateRQ EchoToken="XXX1234" Version="1.0" ReqRespVersion="medium" MaxResponses="16" xmlns="http://www.opentravel.org/OTA/2003/05">
            ...
            ...
            ...
        </OTA_VehAvailRateRQ>
    </ns:Request>
</soap:Body>

...注意那里的额外标签。这是我在努力的地方。有谁知道我应该如何修改原始的XSD以产生额外的标签?

1 个答案:

答案 0 :(得分:1)

这样的事情会在OTA_VehAvailRateRQ之外创建一个Request标签

<xs:schema xmlns:xs=...>

<xs:element name="Request">
<xs:complexType><xs:sequence>
    <xs:element name="OTA_VehAvailRateRQ">
    ...
    </xs:element>
</xs:sequence></xs:complexType>
</xs:element>