XML-RPC Javascript 不支持的方法(“选项”)
我们有一个 XML-RPC 服务器(用 python 实现),我正在尝试编写一个简单的 javascript 应用程序来向它发送调用。无论我创建什么库,我似乎总是会遇到错误:
Unsupported method ('OPTIONS')
可以公平地说,我不理解 XML-RPC 和 HTTP 的底层协议,而我应该理解。但我所知道的是,这在Python中有效:
client = xmlrpclib.ServerProxy('http://localhost:2002')
client.T.run_process()
但以下JavaScript无效:
var client = new xmlrpc_client("", "localhost", 2002, "http")
var msg = new xmlrpcmsg("T.run_process()", {})
lert(client.send(msg));
我正在使用这个 JavaScript 库。但似乎无论我使用什么库,我都会遇到相同的错误,所以我猜我们的服务器不符合 python 不介意的某些协议,对吗?
We've got an XML-RPC server (implemented in python), and I'm trying to write a simple javascript app to send calls to it. Whatever library I make I seem to always get the error:
Unsupported method ('OPTIONS')
It's fair to say I don't understand the underlying protocols for XML-RPC and HTTP as well as I should. But what I do know is that this works in python:
client = xmlrpclib.ServerProxy('http://localhost:2002')
client.T.run_process()
But the following javascript doesn't:
var client = new xmlrpc_client("", "localhost", 2002, "http")
var msg = new xmlrpcmsg("T.run_process()", {})
lert(client.send(msg));
I'm using this javascript library. But it seems I get the same error no matter what library I use, so I guess our server isn't conforming to some protocol that python doesn't mind about, is this right?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用 python 中的标准 SimpleXMLRPCServer,将以下内容添加到 RequestHandler 方法似乎对我有用:
Using the standard SimpleXMLRPCServer from python, adding the following to the RequestHandler methods seemed to work for me:
这可能是 CORS 的实际应用。
This may be CORS in action.
朱利安可能是对的。请参阅此答案< /a> 了解详细信息和更多链接。
Julian is probably right. See this answer for details and some more links.
我最近正在与类似的事情作斗争。
问题是 python 的 XMLRPC 服务器在 XML-RPC 请求中不包含 CORS 标头(也不响应 HTTP OPTIONS 请求)。
我使用 Twisted 来提供 XMLRPC 资源,并解决了向 XMLRPC 请求添加 OPTIONS 响应和标头的问题。
我的代码看起来像这样:
I was fighting against something similar recently.
The problem is that python's XMLRPC server does not include CORS headers (nor respond HTTP OPTIONS request) in the XML-RPC request.
I'm using Twisted to serve the XMLRPC Resource, and solved that adding the OPTIONS response and the headers to the XMLRPC request.
My code looks something like: