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

  • Howto reach AMFHeader in Interceptor?

    Hello,

    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?


    Regards
    GeHe

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

    Comment


    • #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.

      Comment


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

        Code:
        import flex.messaging.io.amf.client.AMFConnection;
        import junit.framework.TestCase;
        
        public class TestBaseService extends TestCase {
        
        	public void testHelo() throws Exception {
                        AMFConnection connection = new AMFConnection();
        		connection.connect("myurl");
                        connection.addAmfHeader("key", "value");
        		Object result = connection.call("myservice.hello");
        	}
        }
        But in the interceptor

        Code:
        import org.springframework.flex.core.MessageInterceptor;
        import org.springframework.flex.core.MessageProcessingContext;
        
        import flex.messaging.messages.Message;
        
        public class FlexInterceptor implements MessageInterceptor {
        
        	@Override
        	public Message postProcess(MessageProcessingContext context, Message inputMessage,
        			Message outputMessage) {
        	outputMessage.setHeader("key_out", "value_out");
        		return outputMessage;
        	}
        
        	@Override
        	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.

        Comment


        • #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:
          inputMessage.getHeaders().get("key");

          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)

          Comment

          Working...
          X