1

我对Spyne 的 hello world 示例感到满意,但是当涉及到更复杂的事情时,我面临缺乏文档和高级示例的问题。就我而言,我有一个接受这样的主体的服务方法

<OTA_HotelAvailRQ xmlns="http://www.opentravel.org/OTA/2003/05" Version="1.0" TimeStamp="2005-08-01T09:30:47+02:00" EchoToken="fb57388d" AvailRatesOnly="true">
  <AvailRequestSegments>
    <AvailRequestSegment AvailReqType="Room">
      <HotelSearchCriteria>
        <Criterion>
          <HotelRef HotelCode="HOTEL1"/>
        </Criterion>
      </HotelSearchCriteria>
    </AvailRequestSegment>
  </AvailRequestSegments>
</OTA_HotelAvailRQ>

你能帮我实现一个接受这种请求的服务吗?

4

1 回答 1

4

在我的头顶上:

class HotelReference(ComplexModel):
    __namespace__ = 'http://www.opentravel.org/OTA/2003/05'

    HotelCode = XmlAttribute(Unicode)

class Criterion(ComplexModel):
    __namespace__ = 'http://www.opentravel.org/OTA/2003/05'

    HotelRef = HotelReference

class AvailRequestSegment(ComplexModel):
    __namespace__ = 'http://www.opentravel.org/OTA/2003/05'

    AvailReqType = XmlAttribute(Unicode(values=["Room", "House", "Condo", "Castle"]))
    HotelSearchCriteria = Criterion.customize(max_occurs='unbounded')

class HotelAvailRQ(ComplexModel):
    __namespace__ = 'http://www.opentravel.org/OTA/2003/05'

    Version = XmlAttribute(Unicode)
    TimeStamp = XmlAttribute(DateTime)
    EchoToken = XmlAttribute(ByteArray)
    AvailRatesOnly XmlAttribute(Boolean)

    AvailRequestSegments = Array(AvailRequestSegment)
于 2013-10-22T13:31:51.543 回答