Update:
When doing this:
response.append_field('status', StatusComplexType)
>
response.append_field('data', SubscriberComplexType)
then it *sometimes* works as expected - and sometimes, ``response.status``
/ ``response.data`` is ``NoneType``. This is very confusing to me.
Thank you!
Fabian
2014-07-31 14:12 GMT+02:00 Fabian Rothfuchs <[email protected]>:
> Hey there,
>
> I'm just in the process of building a SOAP interface. While any SOAP
> interface may return different ComplexTypes, I want all of them to provide
> a ``status`` object as well.
>
> Given my (variable) Payload ComplexType's name is "Subscriber":
>
> FooInterfaceResponse:
>> > Status
>> >> Code
>> >> Message
>> > PayLoad
>> >> Subscriber
>> >>> Name
>> >>> Surname
>> >>> ..
>
>
> My definition:
>
> class SubscriberComplexType(DjangoComplexModel):
>> class Attributes(DjangoComplexModel.Attributes):
>> django_model = Subscriber
>>
>> class StatusComplexType(ComplexModel):
>> code = UnsignedInteger16()
>> message = Unicode()
>> more_info = Unicode()
>>
>> class SubscriberReturnComplexType(ComplexModel):
>> status = StatusComplexType()
>> data = SubscriberComplexType()
>>
>> class SubscriberReadOnlyService(ServiceBase):
>> @rpc(Unicode, _returns=SubscriberReturnComplexType)
>> def getSubscriberByID(self, subscriber_id):
>> """ Returns One Subscriber matching the given ID """
>> response = SubscriberReturnComplexType()
>> try:
>> subscriber =
>> Subscriber.objects.get(subscriber_id=subscriber_id)
>> except Subscriber.DoesNotExist:
>> response.status.code = 404
>> response.status.message = unicode(_(u'Subscriber with ID
>> ``%(subscriber_id)s`` does not exist.' % {'subscriber_id': subscriber_id}))
>> return response
>> response.data = response.data.init_from(subscriber)
>> response.status.code = 200
>> response.status.message = 'OK'
>> return response
>
>
> But this gives me an empty response:
>
> <senv:Envelope xmlns:tns="devicementor" xmlns:senv="
>> http://schemas.xmlsoap.org/soap/envelope/">
>> <senv:Body>
>> <tns:getSubscriberByIDResponse>
>> <tns:getSubscriberByIDResult/>
>> </tns:getSubscriberByIDResponse>
>> </senv:Body>
>> </senv:Envelope>
>
>
> Any idea what I am missing?
>
> Thank you!
> Fabian
>
>
--
*Fabian Rothfuchs*
*Professional IT Services*
*Spilhofstraße 4a*
*D-81927 München (Munich)*
*Germany*
*C: +49 (0) 176 / 322 49 384 *
*P: +49 (0) 89 / 54 89 27 14*
*M: [email protected] <[email protected]>**W: www.rothfuchs.net
<http://www.rothfuchs.net> *
_______________________________________________
Soap mailing list
[email protected]
https://mail.python.org/mailman/listinfo/soap