Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xmlrpc response datatype long possible?

Is there any possibility to allow xmlrpc extensions (datatype long int) for the Python simplexmlrpc server?

The client uses Apache xmlrpc, which allows 8 byte integers.

Basically, I'm using the example code with this function to test it:

def FcnRLong():
    x=8000000000L
    return x

which results in this error:

Java exception occurred:
org.apache.xmlrpc.XmlRpcException: <type 'exceptions.OverflowError'>:long int exceeds XML-RPC limits

Any ideas? Is there any xmlrpc server for Python 2.7 which supports long int?

like image 910
Daniel Avatar asked Dec 26 '22 21:12

Daniel


1 Answers

The second line in the following snippet changes the marshalling for long integers to emit <i8> instead of <int>. Yes, it's not too pretty, but should work and fix the problem.

>>> import xmlrpclib
>>> xmlrpclib.Marshaller.dispatch[type(0L)] = lambda _, v, w: w("<value><i8>%d</i8></value>" % v)
>>> xmlrpclib.dumps((2**63-1,))
'<params>\n<param>\n<value><i8>9223372036854775807</i8></value></param>\n</params>\n'
like image 72
jhermann Avatar answered Dec 28 '22 23:12

jhermann