Internally, xmlrpclib
uses the xmlrpclib.Unmarshaller
to dispatch responses. The Unmarshaller
has a dispatch
dictionary in which each type is assigned a function that will handle it.
Getting the question's example to work is actually quite easy, because xmlrpclib
can already handle i8
and we only have to remap ex:i8
to that:
xmlrpclib.Unmarshaller.dispatch['ex:i8'] = xmlrpclib.Unmarshaller.dispatch['i8']
But for more custom types it might be necessary to write on dispatch functions. Those are designed to be defined within Unmarshaller
, so a typical dispatch function looks like this:
def end_int(self, data):
self.append(int(data))
self._value = 0
dispatch['i8'] = end_int
_value = 0
just indicates that dispatching was successful. So if we had
<methodResponse>
<params>
<param>
<value>
<mycustom>some value</mycustom>
</value>
</param>
</params>
</methodResponse>
we could define:
def mycustom_parser(unmarshaller, data):
unmarshaller.append(data.split())
unmarshaller._value = 0
xmlrpclib.Unmarshaller.dispatch['mycustom'] = mycustom_parser