众所周知,这就是我解决此问题的方法:
我在服务器上创建了一个自定义 HTTPProxyAdapter
public MyHTTPProxyAdapter extends flex.messaging.services.http.HTTPProxyAdapter {
public Object invoke(Message message) {
// modify the message - if required
process(message);
return super.invoke(message);
}
private void process(Message message) {
HTTPMessage http = (HTTPMessage)message;
if(http != null) {
String url = http.getUrl();
ASObject o = (ASObject)http.getBody();
if(o != null) {
Set keys = o.keySet();
Iterator it = keys.iterator();
while(it.hasNext()) {
String key = (String)it.next();
String token = "[" + key +"]";
if(url.contains(token)) {
url = url.replace(token, o.get(key).toString());
o.remove(key);
}
}
http.setUrl(url);
}
}
}
}
然后将目标适配器替换为我的适配器。我现在可以在 config.xml 中使用以下 URL,方括号中的任何内容都将替换为 Query 字符串:
<destination id="user-getbytoken">
<properties>
<url>http://localhost:8080/myapp/public/client/users/token/[id]</url>
</properties>
</destination>
在此示例中,将目标设置为 user-getbytoken 和参数 {id:123} 将导致http://localhost:8080/myapp/public/client/users/token/123的 url