如何使用easyXDM进行跨站POST请求?

发布于 2024-12-19 15:04:33 字数 831 浏览 3 评论 0原文

我想做的是实现一些简单的跨站点客户端调用 RESTful 服务。
现在我正在尝试使用 easyXDM 来实现此目的。 它似乎有效,但是当我根据服务器端的示例(https://github.com/oyvindkinsey/easyXDM#readme)使用它时,我总是得到类似的信息:

GET /?xdm_e=http%3A%2F%2Flocalhost%3A8081&xdm_c=default4817&xdm_p=1 HTTP/1.1
Host: localhost:8080
Connection: keep-alive
Referer: http://localhost:8081/requester.html
User-Agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.30 (KHTML, like Gecko) 
Ubuntu/11.04 Chromium/12.0.742.112 Chrome/12.0.742.112 Safari/534.30
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding: gzip,deflate,sdch
Accept-Language: pl-PL,pl;q=0.8,en-US;q=0.6,en;q=0.4
Accept-Charset: ISO-8859-2,utf-8;q=0.7,*;q=0.3

即使在代码中明确指出:

method: "POST"

有没有办法用easyXDM获得真正的POST请求?
如果没有,那么我应该使用什么工具呢?

What I'm trying to do is to implement some simple cross-site client calls to RESTful service.
Right now I'm trying to use easyXDM for this purpose.
It seems to be working, but when I'm using it according to example (https://github.com/oyvindkinsey/easyXDM#readme) on server side I'm always getting something like:

GET /?xdm_e=http%3A%2F%2Flocalhost%3A8081&xdm_c=default4817&xdm_p=1 HTTP/1.1
Host: localhost:8080
Connection: keep-alive
Referer: http://localhost:8081/requester.html
User-Agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.30 (KHTML, like Gecko) 
Ubuntu/11.04 Chromium/12.0.742.112 Chrome/12.0.742.112 Safari/534.30
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding: gzip,deflate,sdch
Accept-Language: pl-PL,pl;q=0.8,en-US;q=0.6,en;q=0.4
Accept-Charset: ISO-8859-2,utf-8;q=0.7,*;q=0.3

even if it's explicitly said in the code:

method: "POST"

Is there any way to get real POST request with easyXDM?
And if not, then at what tool I should look instead?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

勿挽旧人 2024-12-26 15:04:33

首先我要说的是 easyXDM 完全有能力做到这一点,我用它来完成你所描述的事情。

您可能想要遵循的示例是这样的: http:// easyxdm.net/wp/2010/03/17/cross-domain-ajax/

在我看来,当您配置“RPC”对象时,您正在将端点 url 传递给“远程”参数。这不是 easyXDM 在该参数中所期望的,这就是您遇到这种奇怪行为的原因。

相反,您应该做的是在服务器上安装“index.html”文件(通过 easyXDM 下载提供),并将该 index.html 文件的 url 传递给“remote”参数。然后,您可以在 RPC 对象上调用“请求”时传递端点 url。

如果您按照该链接上的说明进行操作,我保证它会起作用。

Let me first say that easyXDM is totally capable of doing this, I'm using it to do exactly what you're describing.

The example you'll probably want to follow is this: http://easyxdm.net/wp/2010/03/17/cross-domain-ajax/

It appears to me, that when you are configuring your "RPC" object, you are passing your end-point url to the "remote" parameter. That's not what easyXDM expects in that parameter, which is why you experience this strange behavior.

Instead, what you should do is install the "index.html" file (provided with the easyXDM download) on your server, and pass the url to that index.html file to the "remote" parameter. You then pass your endpoint url when calling "request" on the RPC object.

If you follow the instructions on that link I promise you it will work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文