简体   繁体   English

QooxDoo FrontEnd + Python BackEnd(SimpleXMLRPCServer)问题

[英]QooxDoo FrontEnd + Python BackEnd ( SimpleXMLRPCServer) problems

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? 我已经尝试了Qooxdoo,并使用SimpleXMLRPCServer创建了一个简单的Python服务器,并通过Python测试获得了没有问题的数据,但是我可以从Qooxdoo获得此数据吗? I get lost, and I've searched for 3 days but didn't get solutions. 我迷路了,已经搜寻了3天,但没有找到解决方法。

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 http://mieresdelcamin.es/owncloud/public.php?service=files&dir=%2Fjesus%2Ffiles%2FQooxdoo

I tried and read all of qooxdoo-contrib. 我尝试阅读了所有qooxdoo-contrib。


Well, 好,

RpcPython --> Ok RpcPython->确定

and in class/qooxdoo -> test.py 并在课堂/ qooxdoo-> test.py

run server [start-server.py] and query from webroser: 运行服务器[start-server.py]并从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: 在webroser中的回复是:

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

but if i query from qooxdoo like the reply is [error.png] 但是如果我从qooxdoo查询,例如回复为[error.png]

The code for qooxdoo: 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 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 好吧,有了Firebug,owncloud qx.io.remote.ScriptTransport .....中的此错误被检测到

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

Best Regards. 最好的祝福。

I'm guessing you confuse XML-RPC with JSON-RPC and qooxdoo only supports the latter. 我猜想您将XML-RPC与JSON-RPC混淆了,而qooxdoo仅支持后者。 These protocols are similar but the data interchange format is different (XML or JSON). 这些协议相似,但是数据交换格式不同(XML或JSON)。 Instead of the SimpleXMLRPCServer you could use "RpcPython" on the server side which is a qooxdoo contrib project. 代替SimpleXMLRPCServer ,可以在服务器端使用qCoxoxoo contrib项目“ RpcPython”。

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. 之后,您的qooxdoo(客户端)代码也有望工作。 :) :)

Ok, 好,

In the file http.py of qxjsonrc module in the line 66 change 在第66行的qxjsonrc模块的文件http.py中更改

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 http://mieresdelcamin.es/owncloud/public.php?service=files&dir=%2Fjesus%2Ffiles%2FQooxdoo

Best Regards and thanks!!! 最好的问候和感谢!

As Richard already pointed Qooxdoo only supports its flavor of JSON-RPC. 正如Richard指出的那样,Qooxdoo仅支持其JSON-RPC风格。

I maintain a fork of original rpcpython called QooxdooCherrypyJsonRpc . 我维护了一个名为QooxdooCherrypyJsonRpc的原始rpcpython的 分支 The main goal was to hand over transport protocol to some robust framework, and leave only JSON RPC stuff. 主要目标是将传输协议移交给一些健壮的框架,并且仅保留JSON RPC内容。 CherryPy, obviously a robust framework, allows HTTP, WSGI and FastCGI deployment. CherryPy,显然是一个健壮的框架,允许HTTP,WSGI和FastCGI部署。 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): 至少,您的Python后端可能看起来像(称为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: 然后,您可以在qooxdoo代码中进行如下操作:

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. 有关更多信息,请查看我上面发布的软件包页面。

Richard Sternagel wrote about rpcpython. Richard Sternagel写了关于rpcpython的文章。 This version of rpcpython doesn't work with present version of simplejson. 此版本的rpcpython不适用于当前版本的simplejson。 Becouse in json.py have incorrect import: 因为json.py中的导入不正确:

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

Improve rpcpython or use another server, for example CherryPy. 改进rpcpython或使用其他服务器,例如CherryPy。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM