Flex HttpService:附加到目标
我正在使用 Flex 连接到 Rest 服务。 例如,要访问订单 #32,我可以调用 URL http://[service]/orders/32< /a>. URL必须配置为目标 - 因为客户端将连接到服务的不同实例。 所有这些都使用 Blaze 代理,因为它涉及 GET、PUT、DELETE 和 POST 调用。 问题是:- 使用 HttpService 时如何将“32”附加到目的地的末尾? 我所做的就是设置目的地,并在某个时刻将其转换为 URL。 我已经追踪了代码,但我不知道这是在哪里完成的,所以无法替换它。
选项有: 1. 将目标解析为 Flex 客户端内的 URL,然后将该 URL(带有附加数据)设置为 URL。 2. 编写我自己的 java Flex Adapter 来覆盖标准代理,并将参数映射到 url,如下所示: http:// /[service]/order/{id}?id=32 至 http://[service] /order/32
有没有人遇到过这个问题,有什么简单的方法可以解决这个问题吗?
I am using Flex to connect to a Rest service. To access order #32, for instance, I can call the URL http://[service]/orders/32.
The URL must be configured as a destination - since the client will connect to different instances of the service. All of this is using the Blaze Proxy, since it involves GET, PUT, DELETE and POST calls.
The problem is:- how do I append the "32" to the end of a destination when using HttpService? All I do is set the destination, and at some point this is converted into a URL. I have traced the code, but I don't know where this is done, so can't replace it.
Options are:
1. Resolve the destination to a URL within the Flex client, and then set the URL (with the appended data) as the URL.
2. Write my own java Flex Adapter that overrides the standard Proxy, and map parameters to the url like the following: http://[service]/order/{id}?id=32 to http://[service]/order/32
Has anyone come across this problem before, and are there any simple ways to resolve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
大家都知道,这就是我解决此问题的方法:
我在服务器上创建了一个自定义 HTTPProxyAdapter
然后将目标适配器替换为我的适配器。
我现在可以在 config.xml 中使用以下 URL,方括号中的任何内容都将替换为查询字符串:
在此示例中,将目标设置为 user-getbytoken 且参数 {id:123} 将生成以下 url http://localhost:8080/myapp/public/client/users/token/ 123
Just so everyone knows, this is how I resolved this issue:
I created a custom HTTPProxyAdapter on the server
Then replaced the destination adapter to my adapter.
I can now use the following URL in the config.xml and anything in square brackets will be replaced by the Query string:
In this example, setting the destination to user-getbytoken and the parameters {id:123} will result in the url of http://localhost:8080/myapp/public/client/users/token/123
下面是通过单击事件的处理程序将 URL 解析为 Flex 中的 HTTPService 的简单方法。
这是一个服务:
然后是处理程序:
这是一个示例单击事件:
当然,您可以将其他值传递给单击处理程序,甚至让处理程序根据其他当前设置等向 url 添加内容...
希望有帮助!
Here's a simple way to resolve the url to the HTTPService within Flex via the click event's handler.
here's a service:
Then here's the handler:
And here's a sample click event:
Of course you could pass other values to the click handler, or even have the handler add things to the url based on other current settings etc...
Hope that helps!