Nav

@InboundHeaders Annotation

This annotation controls how the current message inbound headers are passed into a method. The annotation supports, Map, List, single headers, wildcards and optional entries. It can be used on component entry points and @Transformer methods.

Accessing Message Information

All messages in Mule have headers. If you need to access the headers, add a parameter to the component method signature or transformer method signature annotated with the @InboundHeaders annotation:

The '*' indicates that all headers should be returned.


         
      
1
2
@Transformer
public Person xmlToPerson(@Payload Document data, @InboundHeaders("*") Map headers)

Wildcard expressions can be used to match a subset of headers too -


         
      
1
2
@Transformer
public Person xmlToPerson(@Payload Document data, @InboundHeaders("X-*") Map headers)

Alternatively, you can specify a single header name and just return the value of that header:


         
      
1
2
@Transformer
public Person xmlToPerson(@Payload InputStream data, @InboundHeaders("Content-Type") String contentType)

To receive a subset of headers, you can list them as comma-separated values:


         
      
1
2
@Transformer
public Person xmlToPerson(@Payload InputStream data, @InboundHeaders("Content-Type, Host, X-MyHeader") Map headers)

By default an error will be thrown if a listed header is not on the response. To avoid this error, mark the header as optional with '?'. For example, X-MyHeader is optional in the following code:


         
      
1
2
@Transformer
public Person xmlToPerson(@Payload InputStream data, @InboundHeaders("Content-Type, Host, X-MyHeader?") Map headers)

If the return type for the @InboundHeaders param is a java.util.List, just the values will be returned.


         
      
1
2
@Transformer
public Person xmlToPerson(@Payload InputStream data, @InboundHeaders("Content-Type, Host, X-MyHeader?") List headers)

We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used and to tailor advertising. You can read more and make your cookie choices here. By continuing to use this site you are giving us your consent to do this.

+