contentTypeXmlFilter is a thin, focused filter that pairs well with response header actions. It is most useful in mixed estates where some endpoints still return XML alongside newer JSON or gRPC services.
Use contentTypeXmlFilter when you want to scope a rule to responses that return XML. The filter inspects the response Content-Type header for the standard XML media types (typically application/xml, text/xml, and the +xml family).
Typical situations:
The filter fires on the responseHeaderReceivedFromRemote scope, so the response headers must already be available. Pair it with response side actions, request scoped actions are not applicable here.
Apply a tag to every XML response coming from a SOAP host so they are easy to filter in the timeline during a debugging session.
rules:
- filter:
typeKind: FilterCollection
operation: and
children:
- typeKind: HostFilter
pattern: soap.example.com
operation: Exact
- typeKind: ContentTypeXmlFilter
actions:
- typeKind: ApplyTagAction
tag:
value: soap-response
Add a CORS header to XML feed responses so a single page application can consume them from a different origin during development.
rules:
- filter:
typeKind: ContentTypeXmlFilter
actions:
- typeKind: AddResponseHeaderAction
headerName: Access-Control-Allow-Origin
headerValue: '*'
Invert the filter to flag responses from a SOAP host that came back with an unexpected non XML body, those are usually error pages from a fronting load balancer.
rules:
- filter:
typeKind: FilterCollection
operation: and
children:
- typeKind: HostFilter
pattern: soap.example.com
operation: Exact
- typeKind: ContentTypeXmlFilter
inverted: true
actions:
- typeKind: ApplyCommentAction
comment: unexpected non-XML response on SOAP host
Select exchanges having XML response body.
Evaluation scope defines the timing where this filter will be applied.
responseHeaderReceivedFromRemote This scope occurs the moment fluxzy has done parsing the response header.
contentTypeXmlFilter
This filter has no specific characteristic
The following table describes the customizable properties available for this filter:
| Property | Type | Description | DefaultValue |
|---|---|---|---|
| inverted | boolean | Negate the filter result | false |
The following examples apply a comment to the filtered exchange
Select exchanges having XML response body.
rules:
- filter:
typeKind: ContentTypeXmlFilter
actions:
- typeKind: ApplyCommentAction
comment: filter was applied
View definition of ContentTypeXmlFilter for .NET integration.
The following filters are related to this filter:
The filter matches the standard XML media types, including application/xml, text/xml and the +xml suffix family such as application/soap+xml or application/atom+xml.
No. contentTypeXmlFilter inspects the response Content-Type header. To match XML in a request body, use a requestHeaderFilter targeting Content-Type.
Yes. Set inverted to true to select every response whose Content-Type is not XML.
The filter cannot match because it has no header to inspect. Fluxzy treats a missing header as not XML.