我尝试过Qooxdoo并使用SimpleXMLRPCServer创建了一个简单的Python服务器,使用Python测试我可以毫无问题地获取数据,但是我可以从Qooxdoo获取这些数据吗?我迷路了,我搜索了3天但没有得到解决方案。
我试试这个:
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, '');
});
我尝试了其他选择,却一无所获:(
文件链接:
http://mieresdelcamin.es/owncloud/public.php?service=files&dir=%2Fjesus%2Ffiles%2FQooxdoo
我尝试并阅读了所有qooxdoo-contrib。
那么,
RpcPython - >好的
并在课堂上/ qooxdoo - > test.py
运行服务器[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]}
并且webroser中的回复是:
qx.io.remote.ScriptTransport._requestFinished(1,{“error”:null,“id”:1,“result”:“客户说:[Por fin]”});
但如果我从qooxdoo查询回复是[error.png]
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");
我输了:((
文件:
http://mieresdelcamin.es/owncloud/public.php?service=files&dir=%2Fjesus%2Ffiles%2FQooxdoo
好吧,使用Firebug在owncloud qx.io.remote.ScriptTransport中的这个错误被检测到了
¿?.............
最诚挚的问候。
答案 0 :(得分:1)
我猜你把XML-RPC和JSON-RPC混淆了,而qooxdoo只支持后者。这些协议类似,但数据交换格式不同(XML或JSON)。而不是SimpleXMLRPCServer
你可以在服务器端使用“RpcPython”,这是一个qooxdoo contrib项目。
请参阅:
启动并运行此服务器后,您应该能够对其进行测试:
之后你的qooxdoo(客户端)代码也有希望。 :)
答案 1 :(得分:0)
好的,
在第66行的qxjsonrc模块的http.py文件中更改
response='qx.io.remote.ScriptTransport._requestFinished(%s,%s);'%(scriptTransportID,response)
代表
response='qx.io.remote.transport.Script._requestFinished(%s,%s);'%(scriptTransportID,response)
运行良好:))
此修改包的链接:
http://mieresdelcamin.es/owncloud/public.php?service=files&dir=%2Fjesus%2Ffiles%2FQooxdoo
最诚挚的问候和感谢!!!
答案 2 :(得分:0)
正如Richard已经指出的那样,Qooxdoo只支持它的JSON-RPC风格。
我维护一个名为QooxdooCherrypyJsonRpc的原始 rpcpython 的分支。主要目标是将传输协议移交给一些健壮的框架,并且只留下JSON RPC的东西。 CherryPy显然是一个健壮的框架,允许HTTP,WSGI和FastCGI部署。代码经过重构并包含在测试中。后来我添加了上传/下载支持和一致的时区日期时间交换。
至少你的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)
然后你可以按照以下方式在你的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);
或直接打开链接:
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
有关详细信息,请查看我上面发布的打包页面。
答案 3 :(得分:-1)
Richard Sternagel写了关于rpcpython的文章。此版本的rpcpython不适用于当前版本的simplejson。在json.py中包含不正确的导入:
from simplejson.decoder import ANYTHING
from simplejson.scanner import Scanner, pattern
改进rpcpython或使用其他服务器,例如CherryPy。