[Soap-Python] Spyne: problems getting complex nested return value definition right
Jussi Rasinmäki
jussi.rasinmaki at simosol.fi
Fri Jul 13 13:20:20 CEST 2012
Hi,
I've got the following test setup defined:
###############################################################################
# TestResponse
###############################################################################
class InvalidValue(ComplexModel):
__namespace__ = 'http://xml.test.org/TestResponse/2012/07/13'
Attr = String
Value = Double
class InvalidValues(ComplexModel):
__namespace__ = 'http://xml.test.org/TestResponse/2012/07/13'
InvalidValue = InvalidValue.customize(min_occurs='1',
max_occurs='unbounded')
class FailedValidation(ComplexModel):
__namespace__ = 'http://xml.test.org/TestResponse/2012/07/13'
id = XmlAttribute(String)
InvalidValues = InvalidValues
Rule = String
class TestResponse(ComplexModel):
__namespace__ = 'http://xml.test.org/TestResponse/2012/07/13'
TaskId = XmlAttribute(String)
FailedValidation = FailedValidation.customize(max_occurs='unbounded')
###############################################################################
# Service classes
###############################################################################
class TestService(ServiceBase):
@rpc(String, _returns=TestResponse)
def TestService(data):
iv1 = InvalidValue(Attr='Basal area', Value=100.)
ivs1 = [iv1]
f1 = FailedValidation(id='10', Rule='Some validation rule',
InvalidValues=ivs1)
iv2 = InvalidValue(Attr='Basal area', Value=100.)
ivs2 = [iv2]
f2 = FailedValidation(id='11', Rule='Some other validation rule',
InvalidValues=ivs2)
fv = [f1, f2]
res = TestResponse(TaskId='1', FailedValidation=fv)
from celery.contrib import rdb;rdb.set_trace()
return res
application = Application([TestService],
'http://ws.test.org/testws/',
interface=Wsdl11(),
in_protocol=Soap11(),
out_protocol=Soap11())
Running it, and dropping to the remote debugger yields:
(Pdb++) res
TestResponse(FailedValidation=[FailedValidation(InvalidValues=[InvalidValue(Attr='Basal
area', Value=100.0)], Rule='Some validation rule', id='10'),
FailedValidation(InvalidValues=[InvalidValue(Attr='Basal area',
Value=100.0)], Rule='Some other validation rule', id='11')],
TaskId='1')
But the returned xml is:
<senv:Body>
<tns:TestServiceResponse>
<tns:TestServiceResult TaskId="1">
<s0:FailedValidation id="10">
<s0:InvalidValues>
<s0:InvalidValue/>
<s0:InvalidValue/>
</s0:InvalidValues>
<s0:Rule>Some validation rule</s0:Rule>
</s0:FailedValidation>
<s0:FailedValidation id="11">
<s0:InvalidValues>
<s0:InvalidValue/>
<s0:InvalidValue/>
</s0:InvalidValues>
<s0:Rule>Some other validation rule</s0:Rule>
</s0:FailedValidation>
</tns:TestServiceResult>
</tns:TestServiceResponse>
</senv:Body>
I.e., no content in the InvalidValue elements although the Python
objects were there.
Doing something wrong here obviously, but what?
Kind regards,
Jussi
More information about the Soap
mailing list