Regarding to a previous question:
I have searched a lot, but everyone wants to modify the body contents or
the headers, not HTTP request method and URI.
I want to modify HTTP request URI and HTTP request method using a CXF
interceptor in a HTTP client.
I have developed something like this:
public class MyInterceptor extends AbstractPhaseInterceptor<Message> {
public MyInterceptor() {
super(Phase.PRE_PROTOCOL);
}
public void handleMessage(Message message) {
// this returns me correct path and method
// String path = (String)
message.getExchange().getOutMessage().get(Message.REQUEST_URI);
// String method = (String)
message.getExchange().getOutMessage().get(Message.HTTP_REQUEST_METHOD);
// this does not work as expected
String path = (String) message.get(Message.REQUEST_URI);
String method = (String)
message.get(Message.HTTP_REQUEST_METHOD);
// do things here
}
}
Questions:
- Why do need I to use exchange/OutMessage to obtain data about current
message and I can not use message directly?
- How can I edit both values? I tried using `message.put(<key>,
<value>)` and the same with exchange/OutMessage, but nothing is modified.
[image: i2cat]
Julio C. Barrera Juez
Office phone: +34 93 357 99 27
Distributed Applications and Networks Area (DANA)
i2CAT Foundation, Barcelona, Spain
http://dana.i2cat.net