0

My testing spyne soap server listen a client that sending a soap request exactly like this:

<EventMessage>
   <Header>
      <Timestamp>2016-01-12T18:22:58.1909735-02:00</Timestamp>
   </Header>
   <MainData>
      <Events>
         <InfoEvent>
            <createdDateTime>2016-01-12T18:22:58.1909735-02:00</createdDateTime>
            <Credential>
               <Names>
                  <name>Bruce Wayne</name>
               </Names>
            </Credential>
            <Details>
               <name>Travel to europe</name>
               <value>Five hundred Euros</value>
            </Details>
            <EventCode ref="323.243.1327.524"/>
         </InfoEvent>
      </Events>
   </MainData>
</EventMessage>

I'm trying create the validation schema, but i can't insert a "ComplexModel" into another "ComplexModel"

How can I put Tag "Name" inside "Credential", "Infoevent" and "Events"?

I'm trying it:

class InfoEvent(ComplexModel):
     createdDateTime = String
    #InfoEvent =  Array(Events, wrapped=False)

class Events(ComplexModel):
    InfoEvent =  Array(InfoEvent, wrapped=False)

class Header(ComplexModel):
    Timestamp = String

class EventMessage(ComplexModel):
    __namespace__ = 'http://iec.ch/TC57/2011/schema/message'

    Header = Header
    MainData = Array(Events, wrapped=False)

but the result is:

  <xs:complexType name="Header">
    <xs:sequence>
      <xs:element name="Timestamp" type="xs:string" minOccurs="0" nillable="true"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="InfoEvent">
    <xs:sequence>
      <xs:element name="createdDateTime" type="xs:string" minOccurs="0" nillable="true"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="Events">
    <xs:sequence>
      <xs:element name="InfoEvent" type="tns:InfoEvent" minOccurs="0" maxOccurs="unbounded" nillable="true"/>
    </xs:sequence>
  </xs:complexType>
  <xs:element name="Header" type="tns:Header"/>
  <xs:element name="InfoEvent" type="tns:InfoEvent"/>
  <xs:element name="Events" type="tns:Events"/>

Can someone help me, please?

keyvan vafaee
  • 464
  • 4
  • 15
pazt
  • 11
  • 1
  • 3

1 Answers1

0

In your service, try adding polymorphic = True to the outbound protocol.

app = Application([service],
                  'whatever.whatever',
                  in_protocol=Soap11(validator='lxml'),
                  out_protocol=Soap11(polymorphic=True)
                 )