From fabian at rothfuchs.net Thu Jul 31 14:12:57 2014 From: fabian at rothfuchs.net (Fabian Rothfuchs) Date: Thu, 31 Jul 2014 14:12:57 +0200 Subject: [Soap-Python] ComplexType Within ComplexTypes in Django ? Message-ID: 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: > > > > > > Any idea what I am missing? Thank you! Fabian -------------- next part -------------- An HTML attachment was scrubbed... URL: From fabian at rothfuchs.net Thu Jul 31 14:22:36 2014 From: fabian at rothfuchs.net (Fabian Rothfuchs) Date: Thu, 31 Jul 2014 14:22:36 +0200 Subject: [Soap-Python] ComplexType Within ComplexTypes in Django ? In-Reply-To: References: Message-ID: 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 : > 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: > > >> >> >> >> >> >> > > > 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: fabian at rothfuchs.net **W: www.rothfuchs.net * -------------- next part -------------- An HTML attachment was scrubbed... URL: From fabian at rothfuchs.net Thu Jul 31 17:31:50 2014 From: fabian at rothfuchs.net (Fabian Rothfuchs) Date: Thu, 31 Jul 2014 17:31:50 +0200 Subject: [Soap-Python] ComplexType Within ComplexTypes in Django ? In-Reply-To: References: Message-ID: Hey there, I got this solved by defining a sequence as ``_returns`` : > > @rpc(Unicode, _returns=(StatusComplexType, SubscriberComplexType), _out_variable_names=('status', 'result')) > def getSubscriberByID(self, subscriber_id): > """ Returns One Subscriber matching the given ID """ > > status = StatusComplexType() > > try: > subscriber = Subscriber.objects.get(subscriber_id=subscriber_id) > except Subscriber.DoesNotExist: > status.code = 404 > status.message = unicode(_(u'Subscriber with ID ``%(subscriber_id)s`` does not exist.' % {'subscriber_id': subscriber_id})) > return (status,) > > status.code = 200 > status.message = 'OK' > > return (status, subscriber) Cheers Fabian > On 31 Jul 2014, at 14:22, Fabian Rothfuchs wrote: > > 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 : > 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: > > > > > > > > > > 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: fabian at rothfuchs.net > W: www.rothfuchs.net > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: