Announcement Announcement Module
No announcement yet.
Howto reach AMFHeader in Interceptor? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Howto reach AMFHeader in Interceptor?


    the title says it all. I have registered an MessageInterceptor and try to get
    the header out. But i can not reach them through the MessageProcessingContext context or Message inputMessage.
    By debugging i noticed that in the MessageBrokerFilter they are in the ActionContext.requestMessage.requestHeaders. How can i get them in the Interceptor?


  • #2
    I also noticed, that outgoing header are not received, not set in the outgoing message?


    • #3
      Can you provide more details as to what exactly isn't there that you are expecting? You should definitely be able to get to the headers through the Message interface.


      • #4
        Thank you for response. I have written a testclient to try spring blazeds integration with headers.

        import junit.framework.TestCase;
        public class TestBaseService extends TestCase {
        	public void testHelo() throws Exception {
                        AMFConnection connection = new AMFConnection();
                        connection.addAmfHeader("key", "value");
        		Object result ="myservice.hello");
        But in the interceptor

        import org.springframework.flex.core.MessageInterceptor;
        import org.springframework.flex.core.MessageProcessingContext;
        import flex.messaging.messages.Message;
        public class FlexInterceptor implements MessageInterceptor {
        	public Message postProcess(MessageProcessingContext context, Message inputMessage,
        			Message outputMessage) {
        	outputMessage.setHeader("key_out", "value_out");
        		return outputMessage;
        	public Message preProcess(MessageProcessingContext context, Message inputMessage) {
        		// control incoming msgs
        		String header = (String) inputMessage.getHeader("key");
        		return inputMessage;
        i do net geht the header "key" (and the set header "key_out" does not get out). When i debug just before the interceptor (flex.messaging.endpoints.amf.MessageBrokerFilter. invoke(final ActionContext context)) i can see the header in the context.requestMessage.requestHeaders.

        Conclusion: I expected the header to retrieve by inputMessage.getHeader("key"); - it is there, but i do not get it.


        • #5
          I haven't seen any API method to get to a specific header yet. But, there is a getHeaders() method which returns a Map for the message headers. You should be able to then use the get("headerNameAsKey") to get the value of a specific message meader.

          Code snippet:

          or... directly get the list of values and iterate through...

          Collection headers = message.getHeaders().values();
          for(Object header:headers) {
          // read the header or do something

          To set the header the method is :
          inputMessage.setHeaders(Map map)