0

I have tried Qooxdoo and I made a simple Python server with SimpleXMLRPCServer, with a Python test I get the data without problems, but can I get this data from Qooxdoo? I get lost, and I've searched for 3 days but didn't get solutions.

I try this:

var JSON_lista_empresas = 1000
button1.addListener("execute", function(e) 
{
    var rpc = new qx.io.remote.Rpc();
    rpc.setServiceName("get_data");
    //rpc.setCrossDomain(true);
    rpc.setUrl("http://192.168.1.54:46000");
    rpc.addListener("completed", function(event)
    {
        console.log(event.getData());
    });
    rpc.callAsync( JSON_lista_empresas, '');
});

And I tried other options but got nothing :(

The link to files:

http://mieresdelcamin.es/owncloud/public.php?service=files&dir=%2Fjesus%2Ffiles%2FQooxdoo

I tried and read all of qooxdoo-contrib.


Well,

RpcPython --> Ok

and in class/qooxdoo -> test.py

run server [start-server.py] and query from webroser:

http://127.0.0.1:8000//?_ScriptTransport_id=1&nocache=1366909868006&_ScriptTransport_data={%22service%22%3A%22qooxdoo.test%22%2C%22method%22%3A%22echo%22%2C%22id%22%3A1%2C%22params%22%3A[%22Por%20fin%22]}

and the reply in webroser is:

qx.io.remote.ScriptTransport._requestFinished(1,{"error": null, "id": 1, "result": "Client said: [ Por fin ]"});

but if i query from qooxdoo like the reply is [error.png]

The code for qooxdoo:

var rpc = new qx.io.remote.Rpc( "http://127.0.0.1:8000/");
    rpc.setCrossDomain( true);
    rpc.setServiceName( 'qooxdoo.test');
// asynchronous call
    var handler = function(result, exc) {
        if (exc == null) {
            alert("Result of async call: " + result);
        } else {
            alert("Exception during async call: " + exc+ result);
        }
    };
rpc.callAsync(handler, "echo", "Por fin");

I lost :((

Files in:

http://mieresdelcamin.es/owncloud/public.php?service=files&dir=%2Fjesus%2Ffiles%2FQooxdoo

Well, with Firebug this error in owncloud qx.io.remote.ScriptTransport.....is detect

¿?.............

Best Regards.

Jesús
  • 1
  • 1

4 Answers4

1

I'm guessing you confuse XML-RPC with JSON-RPC and qooxdoo only supports the latter. These protocols are similar but the data interchange format is different (XML or JSON). Instead of the SimpleXMLRPCServer you could use "RpcPython" on the server side which is a qooxdoo contrib project.

See:

Once you have this server up and running you should be able to test it:

After that your qooxdoo (client) code hopefully works also. :)

0

Ok,

In the file http.py of qxjsonrc module in the line 66 change

response='qx.io.remote.ScriptTransport._requestFinished(%s,%s);'%(scriptTransportID,response)

for

response='qx.io.remote.transport.Script._requestFinished(%s,%s);'%(scriptTransportID,response)

And run fine :))

This link for package modified:

http://mieresdelcamin.es/owncloud/public.php?service=files&dir=%2Fjesus%2Ffiles%2FQooxdoo

Best Regards and thanks!!!

Jesús
  • 1
  • 1
0

As Richard already pointed Qooxdoo only supports its flavor of JSON-RPC.

I maintain a fork of original rpcpython called QooxdooCherrypyJsonRpc. The main goal was to hand over transport protocol to some robust framework, and leave only JSON RPC stuff. CherryPy, obviously a robust framework, allows HTTP, WSGI and FastCGI deployment. Code was refactored and covered with tests. Later I added upload/download support and consistent timezone datetime interchange.

At very minimum your Python backend may look like (call it test.py):

import cherrypy
import qxcpjsonrpc as rpc

class Test(rpc.Service):

  @rpc.public
  def add(self, x, y):
    return x + y

config = {
  '/service' : {
    'tools.jsonrpc.on' : True
  },
  '/resource' : {
    'tools.staticdir.on'  : True,
    'tools.staticdir.dir' : '/path/to/your/built/qooxdoo/app'
  }
}
cherrypy.tools.jsonrpc = rpc.ServerTool()

if __name__ == '__main__':
  cherrypy.quickstart(config = config)

Then you can do in your qooxdoo code as follows:

var rpc = new qx.io.remote.Rpc();
rpc.setServiceName('test.Test');
rpc.setUrl('http://127.0.0.1:8080/service');
rpc.setCrossDomain(true); // you need this for opening app from file://
rpc.addListener("completed", function(event)
{
  console.log(event.getData());
});
rpc.callAsyncListeners(this, 'add', 5, 7);

Or open the link directly:

http://127.0.0.1:8080/service?_ScriptTransport_id=1&_ScriptTransport_data=%7B%22params%22%3A+%5B12%2C+13%5D%2C+%22id%22%3A+1%2C+%22service%22%3A+%22test.Test%22%2C+%22method%22%3A+%22add%22%7D

For more info take a look at the package page I posted above.

saaj
  • 23,253
  • 3
  • 104
  • 105
-1

Richard Sternagel wrote about rpcpython. This version of rpcpython doesn't work with present version of simplejson. Becouse in json.py have incorrect import:

    from simplejson.decoder import ANYTHING
    from simplejson.scanner import Scanner, pattern

Improve rpcpython or use another server, for example CherryPy.

Port
  • 86
  • 12