Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Tuple in Java XMLRPC

I'm trying to pass python tuple over java xmlrpc. Here is library what I'm using: XMLPRC Java Libray

I'm using odoo framework on server and api. I want to pass argument which will looks like:

[(4,7),(4,8)]

I'm able to pass following structure:

[[4,7],[4,8]]

which is clearly array inside array like:

new Object[]{new Object[]{4,7},new Object[]{4,8}}

The problem is there is no tuple in java. What I absorb is how to transform this structure:

This [4,8] to This(4,8)

It is some kind of serialization issue what don't know how to resolve it and pass expected python structure.

like image 758
Ashish Sahu Avatar asked Feb 08 '17 06:02

Ashish Sahu


People also ask

What is XML-RPC Python?

XML-RPC is a Remote Procedure Call method that uses XML passed via HTTP as a transport. With it, a client can call methods with parameters on a remote server (the server is named by a URI) and get back structured data. xmlrpc is a package that collects server and client modules implementing XML-RPC.

How do I enable Allow_none on XML-RPC?

In your server class, add allow_none=True to your SimpleXMLRPCServer instantiation. The allow_none and encoding parameters are passed on to xmlrpc. client and control the XML-RPC responses that will be returned from the server.

What is ServerProxy in Python?

A ServerProxy instance is an object that manages communication with a remote XML-RPC server. The required first argument is a URI (Uniform Resource Indicator), and will normally be the URL of the server.

How does XML-RPC work?

In XML-RPC, a client performs an RPC by sending an HTTP request to a server that implements XML-RPC and receives the HTTP response. A call can have multiple parameters and one result. The protocol defines a few data types for the parameters and result. Some of these data types are complex, i.e. nested.


1 Answers

Is there a problem with [[4,7],[4,8]] ? Most python operations don't differ tuples from actual lists. And in Odoo even less. I think that this is the proper way to send a list of tuples through languages that does not implement tuples. Tuple is not a key, value thing. You can have (a, b, c) which is a tuple. That is somewhat similar to [a, b, c]. You can iterate on both. You can get their value through indexes (if both were stored in a element variable, getting a from it would be element[0] for them both).

So if you have a problem, I don't think it's about tuples and you did not answer the comment asking if there is an error on the XMLRPC call. My guess is there is no error. And if there is an error, I'm sure it's not about tuples.

like image 173
Majikat Avatar answered Oct 06 '22 00:10

Majikat