Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.此内容没有您所选择的语言版本。
Chapter 42. Filtering SOAP Message Headers
Abstract
The Camel CXF component supports a flexible header filtering mechanism, which enables you to process SOAP headers, applying different filters according to the header's XML namespace.
42.1. Basic Configuration 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
Overview 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
When more than one CXF endpoint appears in a route, you need to decide whether or not to allow headers to propagate between the endpoints. By default, the headers are relayed back and forth between the endpoints, but in many cases it might be necessary to filter the headers or to block them altogether. You can control header propagation by applying filters to producer endpoints.
CxfHeaderFilterStrategy 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
Header filtering is controlled by the
CxfHeaderFilterStrategy class. Basic configuration of the CxfHeaderFilterStrategy class involves setting one or more of the following options:
relayHeaders option 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
The semantics of the
relayHeaders option can be summarized as follows:
| In-band headers | Out-of-band headers | |
relayHeaders=true, dataFormat=PAYLOAD | Filter | Filter |
relayHeaders=true, dataFormat=POJO | Relay all | Filter |
relayHeaders=false | Block | Block |
In-band headers 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
An in-band header is a header that is explicitly defined as part of the WSDL binding contract for an endpoint.
Out-of-band headers 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
An out-of-band header is a header that is serialized over the wire, but is not explicitly part of the WSDL binding contract. In particular, the SOAP binding permits out-of-band headers, because the SOAP specification does not require headers to be defined in the WSDL contract.
Payload format 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
The CXF endpoint's payload format affects the filter behavior as follows:
POJO- (Default) Only out-of-band headers are available for filtering, because the in-band headers have already been processed and removed from the list by CXF. The in-band headers are incorporated into the
MessageContentListin POJO mode. If you require access to headers in POJO mode, you have the option of implementing a custom CXF interceptor or JAX-WS handler. PAYLOAD- In this mode, both in-band and out-of-band headers are available for filtering.
MESSAGE- Not applicable. (In this mode, the message remains in a raw format and the headers are not processed at all.)
Default filter 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
The default filter is of type,
SoapMessageHeaderFilter, which removes only the SOAP headers that the SOAP specification expects an intermediate Web service to consume. For more details, see the section called “SoapMessageHeaderFilter”.
Overriding the default filter 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
You can override the default
CxfHeaderFilterStrategy instance by defining a new CxfHeaderFilterStrategy bean and associating it with a CXF endpoint.
Sample relayHeaders configuration 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
The following example shows how you can use the
relayHeaders option to create a CxfHeaderFilterStrategy bean that blocks all message headers. The CXF endpoints in the route use the headerFilterStrategy option to install the filter strategy in the endpoint, where the headerFilterStrategy setting has the syntax, headerFilterStrategy=#BeanID.
relayAllMessageHeaders option 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
The
relayAllMessageHeaders option is used to propagate all SOAP headers, without applying any filtering (any installed filters would be bypassed). In order to enable this feature, you must set both relayHeaders and relayAllMessageHeaders to true.
Sample relayAllMessageHeaders configuration 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
The following example shows how to configure CXF endpoints to propagate all SOAP message headers. The
propagateAllMessages filter strategy sets both relayHeaders and relayAllMessageHeaders to true.