@Transformer
public Person xmlToPerson(@Payload Document data, @InboundHeaders("*") Map headers)
@InboundHeaders Annotation
Mule runtime engine version 3.8 reached its End of Life on November 16, 2021. For more information, contact your Customer Success Manager to determine how to migrate to the latest Mule version. |
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.
Wildcard expressions can be used to match a subset of headers too -
@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:
@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:
@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:
@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.
@Transformer
public Person xmlToPerson(@Payload InputStream data, @InboundHeaders("Content-Type, Host, X-MyHeader?") List headers)