Xmlrpc response data type can be long?

Is it possible to enable xmlrpc extensions (datatype long int ) for Python simplexmlrpc server?

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

Basically, I use sample code with this function to test it:

 def FcnRLong(): x=8000000000L return x 

leading to this error:

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

Any ideas? Is there an xmlrpc server for Python 2.7 that supports long int ?

+4
source share
1 answer

The second line in the following snippet modifies marshalling for long integers to emit <i8> instead of <int> . Yes, this is 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' 
+9
source

Source: https://habr.com/ru/post/1499795/


All Articles