I'm working with spyne 2.12.14 in python 2.7 and django 1.9 I want to return a response like this:
?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<ns2:GetResponse xmlns:ns2="http://test.example.com/test">
<return>
<myHeader>
<id>1234abc</id>
<code>000</code>
<message>Success</message>
</myHeader>
<MyDetail>
<item1>myItem1</item1>
<item2>myItem2</item2>
</MyDetail>
<MyDetail>
<item1>myItem1</item1>
<item2>myItem2</item2>
</MyDetail>
</return>
</ns2:GetResponse>
</soapenv:Body>
</soapenv:Envelope>
but get this response:
?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<ns2:GetResponse xmlns:ns2="http://test.example.com/test">
<return>
<myHeader>
<id>1234abc</id>
<code>000</code>
<message>Success</message>
</myHeader>
<MyDetail>
<MyDetail>
<item1>myItem1</item1>
<item2>myItem2</item2>
</MyDetail>
<MyDetail>
<item1>myItem1</item1>
<item2>myItem2</item2>
</MyDetail>
</MyDetail>
</return>
</ns2:GetResponse>
</soapenv:Body>
</soapenv:Envelope>
This is my code:
class MyHeader(ComplexModel):
__namespace__ = 'http://test.example.com/test'
INHERITANCE = None,
INDICATOR = Sequence,
_type_info = {
'id': String,
'code': String,
'message': String,
}
class MyDetail(ComplexModel):
__namespace__ = 'http://test.example.com/test'
INHERITANCE = None,
INDICATOR = Sequence,
_type_info = {
'item1': String,
'item2': String,
}
class GetResponse(ComplexModel):
INHERITANCE = None,
INDICATOR = Sequence,
_type_info = {
'myHeader': MyHeader,
'MyDetail': Array(MyDetail, minOccurs=0, maxOccurs='unbounded')
}
@rpc(MyObject, _returns=[GetResponse], _out_variable_names=["return"])
def GetMiniStatement(ctx, MyObjectInfo):
do_something
Can anyone help please?
change my declaration to that 'MyDetail': Array(MyDetail, maxOccurs='unbounded', wrapped = False) and it works.