Results 1 to 5 of 5

Thread: Howto reach AMFHeader in Interceptor?

  1. #1
    Join Date
    Nov 2008
    Posts
    5

    Default 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. #2
    Join Date
    Nov 2008
    Posts
    5

    Default

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

  3. #3
    Join Date
    Apr 2005
    Location
    San Francisco, CA
    Posts
    1,224

    Default

    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.
    Jeremy Grelle

    Staff Engineer, Web Products Team
    SpringSource

  4. #4
    Join Date
    Nov 2008
    Posts
    5

    Default

    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.

  5. #5

    Default

    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)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •