我对Spyne's hello world examples没问题,但是当涉及到更复杂的事情时,我遇到了缺乏文档和高级示例的问题。在我的情况下,我有一个接受这样的身体的服务方法
<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>
您能帮我实现接受此类请求的服务吗?
答案 0 :(得分:3)
脱离我的头顶:
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)