This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch backport/30212-to-camel-4-22-x
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 0669896f2ddf684487b7d77eadb31f76a0388898
Author: Claus Ibsen <[email protected]>
AuthorDate: Wed Nov 18 21:12:47 2026 +0100

    CAMEL-27052: camel-jaxb - the part class and namespace headers are used 
only when allowPartClassFromHeader is enabled (#30212)
    
    The JAXB data format always read the CamelJaxbPartClass and 
CamelJaxbPartNamespace headers, on unmarshal and marshal,
    and when set they took precedence over the partClass and partNamespace 
options. A new option allowPartClassFromHeader
    (default false) makes them opt-in, in line with allowUnmarshallType of the 
Jackson, Gson and JSON-B data formats. When
    disabled, the headers are ignored and the configured partClass and 
partNamespace apply.
    
    - The SOAP data format extends the JAXB data format and always ignores 
these headers; it has no such option, as a part
      class from a header always fails there with "Expected Soap Envelope".
    - The Rest DSL binding does not take allowPartClassFromHeader from the JAXB 
data format on the CamelContext (it is in
      RestBindingAdviceFactory.NOT_INHERITED_OPTIONS, next to partClass); set 
it with the xml.in./xml.out. data format
      property when the binding needs it.
    - Docs, the 4.24 upgrade guide and the regenerated metadata, catalog and 
DSL parsers and schemas.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
    (cherry picked from commit f8036a4c935488138414bdc53d575aa4c4208d4b)
    Signed-off-by: Claus Ibsen <[email protected]>
---
 .../org/apache/camel/catalog/dataformats/jaxb.json |  15 +--
 .../apache/camel/catalog/docs/jaxb-dataformat.adoc |  26 +++--
 .../org/apache/camel/catalog/models/jaxb.json      |  15 +--
 .../apache/camel/catalog/schemas/camel-spring.xsd  |  11 ++
 .../apache/camel/catalog/schemas/camel-xml-io.xsd  |  11 ++
 .../camel/catalog/schemas/camelYamlDsl-model.json  |  25 +++--
 .../converter/jaxb/JaxbDataFormatConfigurer.java   |   7 ++
 .../org/apache/camel/converter/jaxb/jaxb.json      |  15 +--
 .../camel-jaxb/src/main/docs/jaxb-dataformat.adoc  |  26 +++--
 .../camel/converter/jaxb/JaxbDataFormat.java       |  24 +++-
 .../jaxb/JaxbDataFormatPartClassHeaderTest.java    |   1 +
 .../jaxb/JaxbPartClassHeaderOptionTest.java        | 124 +++++++++++++++++++++
 .../JaxbPartClassHeaderStatePollutionTest.java     |   2 +
 .../rest/RestJettyNoContentRestConfigTest.java     |   3 +-
 .../jetty/rest/RestJettyNoContentTest.java         |   3 +-
 .../rest/RestServletNoContentRestConfigTest.java   |   3 +-
 .../servlet/rest/RestServletNoContentTest.java     |   3 +-
 .../camel/dataformat/soap/SoapUnMarshalTest.java   |  15 +++
 .../org/apache/camel/model/dataformat/jaxb.json    |  15 +--
 .../camel/model/dataformat/JaxbDataFormat.java     |  38 +++++++
 .../reifier/dataformat/JaxbDataFormatReifier.java  |   1 +
 .../apache/camel/java/out/JavaDslModelWriter.java  |   1 +
 .../java/org/apache/camel/xml/in/ModelParser.java  |   1 +
 .../java/org/apache/camel/xml/out/ModelWriter.java |   1 +
 .../org/apache/camel/yaml/out/YamlModelWriter.java |   1 +
 .../dsl/yaml/deserializers/ModelDeserializers.java |   6 +
 .../resources/schema/camelYamlDsl-canonical.json   |   6 +
 .../resources/schema/camelYamlDsl-model.json       |  25 +++--
 .../generated/resources/schema/camelYamlDsl.json   |   6 +
 29 files changed, 367 insertions(+), 63 deletions(-)

diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dataformats/jaxb.json
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dataformats/jaxb.json
index 2a2e425cabd9..1a624c0bfbc5 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dataformats/jaxb.json
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dataformats/jaxb.json
@@ -30,12 +30,13 @@
     "fragment": { "index": 11, "kind": "attribute", "displayName": "Fragment", 
"group": "advanced", "label": "advanced", "required": false, "type": "boolean", 
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": false, "description": "To turn on marshalling 
XML fragment trees. This is useful when generated code does not have 
XmlRootElement annotation and you need to unmarshall only part of the tree." },
     "partClass": { "index": 12, "kind": "attribute", "displayName": "Part 
Class", "group": "advanced", "label": "advanced", "required": false, "type": 
"string", "javaType": "java.lang.String", "deprecated": false, "autowired": 
false, "secret": false, "description": "Name of class used for fragment 
parsing." },
     "partNamespace": { "index": 13, "kind": "attribute", "displayName": "Part 
Namespace", "group": "advanced", "label": "advanced", "required": false, 
"type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "description": "XML namespace to use for 
fragment parsing." },
-    "namespacePrefix": { "index": 14, "kind": "attribute", "displayName": 
"Namespace Prefix", "group": "advanced", "label": "advanced", "required": 
false, "type": "object", "javaType": "java.util.Map", "deprecated": false, 
"autowired": false, "secret": false, "description": "When marshalling using 
JAXB or SOAP then the JAXB implementation will automatically assign namespace 
prefixes, such as ns2, ns3, ns4 etc. To control this mapping, Camel allows you 
to refer to a map which contains the [...]
-    "xmlStreamWriterWrapper": { "index": 15, "kind": "attribute", 
"displayName": "Xml Stream Writer Wrapper", "group": "advanced", "label": 
"advanced", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "To use a custom xml stream writer." },
-    "schemaLocation": { "index": 16, "kind": "attribute", "displayName": 
"Schema Location", "group": "common", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "autowired": false, 
"secret": false, "description": "To define the location of the schema." },
-    "noNamespaceSchemaLocation": { "index": 17, "kind": "attribute", 
"displayName": "No Namespace Schema Location", "group": "advanced", "label": 
"advanced", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "To define the location of the namespaceless schema." },
-    "jaxbProviderProperties": { "index": 18, "kind": "attribute", 
"displayName": "Jaxb Provider Properties", "group": "advanced", "label": 
"advanced", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "Refers to a custom java.util.Map to lookup in the registry 
containing custom JAXB provider properties to be used with the JAXB 
marshaller." },
-    "contentTypeHeader": { "index": 19, "kind": "attribute", "displayName": 
"Content Type Header", "group": "common", "required": false, "type": "boolean", 
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": true, "description": "Whether the data format 
should set the Content-Type header with the type from the data format. For 
example application\/xml for data formats marshalling to XML, or 
application\/json for data formats marshall [...]
-    "accessExternalSchemaProtocols": { "index": 20, "kind": "attribute", 
"displayName": "Access External Schema Protocols", "group": "security", 
"label": "security", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "Only in use if schema validation has been enabled. Restrict 
access to the protocols specified for external reference set by the 
schemaLocation attribute, Import and Include element." }
+    "allowPartClassFromHeader": { "index": 14, "kind": "attribute", 
"displayName": "Allow Part Class From Header", "group": "advanced", "label": 
"advanced", "required": false, "type": "boolean", "javaType": 
"java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": false, "description": "Whether the CamelJaxbPartClass and 
CamelJaxbPartNamespace headers are used, when set, instead of the partClass and 
partNamespace options when marshalling and unmarshal [...]
+    "namespacePrefix": { "index": 15, "kind": "attribute", "displayName": 
"Namespace Prefix", "group": "advanced", "label": "advanced", "required": 
false, "type": "object", "javaType": "java.util.Map", "deprecated": false, 
"autowired": false, "secret": false, "description": "When marshalling using 
JAXB or SOAP then the JAXB implementation will automatically assign namespace 
prefixes, such as ns2, ns3, ns4 etc. To control this mapping, Camel allows you 
to refer to a map which contains the [...]
+    "xmlStreamWriterWrapper": { "index": 16, "kind": "attribute", 
"displayName": "Xml Stream Writer Wrapper", "group": "advanced", "label": 
"advanced", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "To use a custom xml stream writer." },
+    "schemaLocation": { "index": 17, "kind": "attribute", "displayName": 
"Schema Location", "group": "common", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "autowired": false, 
"secret": false, "description": "To define the location of the schema." },
+    "noNamespaceSchemaLocation": { "index": 18, "kind": "attribute", 
"displayName": "No Namespace Schema Location", "group": "advanced", "label": 
"advanced", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "To define the location of the namespaceless schema." },
+    "jaxbProviderProperties": { "index": 19, "kind": "attribute", 
"displayName": "Jaxb Provider Properties", "group": "advanced", "label": 
"advanced", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "Refers to a custom java.util.Map to lookup in the registry 
containing custom JAXB provider properties to be used with the JAXB 
marshaller." },
+    "contentTypeHeader": { "index": 20, "kind": "attribute", "displayName": 
"Content Type Header", "group": "common", "required": false, "type": "boolean", 
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": true, "description": "Whether the data format 
should set the Content-Type header with the type from the data format. For 
example application\/xml for data formats marshalling to XML, or 
application\/json for data formats marshall [...]
+    "accessExternalSchemaProtocols": { "index": 21, "kind": "attribute", 
"displayName": "Access External Schema Protocols", "group": "security", 
"label": "security", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "Only in use if schema validation has been enabled. Restrict 
access to the protocols specified for external reference set by the 
schemaLocation attribute, Import and Include element." }
   }
 }
diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/jaxb-dataformat.adoc
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/jaxb-dataformat.adoc
index 3a37dcbd991c..0a4c18f9693b 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/jaxb-dataformat.adoc
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/jaxb-dataformat.adoc
@@ -96,23 +96,35 @@ need to unmarshall only part of the tree.
 
 In that case, you can use partial unmarshalling. To enable this
 behavior, you need set property `partClass` on the `JaxbDataFormat`. Camel 
will pass this class
-to the JAXB unmarshaller. If `CamelJaxbPartClass` is set as
-one of the exchange headers, its value is used to override the `partClass` 
property
-on the `JaxbDataFormat`.
+to the JAXB unmarshaller.
 
 For marshalling you have to add the `partNamespace` attribute with the `QName` 
of
 the destination namespace.
 
-If `CamelJaxbPartNamespace` is set as
-one of the exchange headers, its value is used to override the `partNamespace` 
property
-on the `JaxbDataFormat`.
+==== Choosing the part class with headers
+
+To choose the part class and namespace per message, enable the 
`allowPartClassFromHeader` option
+(default `false`). Then the following exchange headers, when set, are used 
instead of the
+`partClass` and `partNamespace` options on the `JaxbDataFormat`:
+
+* `CamelJaxbPartClass`: the class name used instead of `partClass`, when 
marshalling and unmarshalling.
+* `CamelJaxbPartNamespace`: the namespace used instead of `partNamespace`, 
when marshalling.
+
+When `allowPartClassFromHeader` is `false`, these headers are ignored.
 
 While setting `partNamespace` through the `CamelJaxbPartNamespace` header, 
please
 note that you need to specify its value in the format 
`\{namespaceUri\}localPart`, as per the example below.
 
 [source,java]
 ----
-.setHeader("CamelJaxbPartNamespace", 
constant("{http://www.camel.apache.org/jaxb/example/address/1}address";));
+JaxbDataFormat jaxb = new JaxbDataFormat("com.mycompany.model");
+jaxb.setAllowPartClassFromHeader(true);
+
+from("direct:start")
+    .setHeader("CamelJaxbPartClass", constant("com.mycompany.model.Address"))
+    .setHeader("CamelJaxbPartNamespace", 
constant("{http://www.camel.apache.org/jaxb/example/address/1}address";))
+    .marshal(jaxb)
+    .to("mock:result");
 ----
 
 === Fragment
diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/jaxb.json
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/jaxb.json
index 1e87633c772a..8daabff5a2ed 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/jaxb.json
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/jaxb.json
@@ -27,12 +27,13 @@
     "fragment": { "index": 11, "kind": "attribute", "displayName": "Fragment", 
"group": "advanced", "label": "advanced", "required": false, "type": "boolean", 
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": false, "description": "To turn on marshalling 
XML fragment trees. This is useful when generated code does not have 
XmlRootElement annotation and you need to unmarshall only part of the tree." },
     "partClass": { "index": 12, "kind": "attribute", "displayName": "Part 
Class", "group": "advanced", "label": "advanced", "required": false, "type": 
"string", "javaType": "java.lang.String", "deprecated": false, "autowired": 
false, "secret": false, "description": "Name of class used for fragment 
parsing." },
     "partNamespace": { "index": 13, "kind": "attribute", "displayName": "Part 
Namespace", "group": "advanced", "label": "advanced", "required": false, 
"type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "description": "XML namespace to use for 
fragment parsing." },
-    "namespacePrefix": { "index": 14, "kind": "attribute", "displayName": 
"Namespace Prefix", "group": "advanced", "label": "advanced", "required": 
false, "type": "object", "javaType": "java.util.Map", "deprecated": false, 
"autowired": false, "secret": false, "description": "When marshalling using 
JAXB or SOAP then the JAXB implementation will automatically assign namespace 
prefixes, such as ns2, ns3, ns4 etc. To control this mapping, Camel allows you 
to refer to a map which contains the [...]
-    "xmlStreamWriterWrapper": { "index": 15, "kind": "attribute", 
"displayName": "Xml Stream Writer Wrapper", "group": "advanced", "label": 
"advanced", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "To use a custom xml stream writer." },
-    "schemaLocation": { "index": 16, "kind": "attribute", "displayName": 
"Schema Location", "group": "common", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "autowired": false, 
"secret": false, "description": "To define the location of the schema." },
-    "noNamespaceSchemaLocation": { "index": 17, "kind": "attribute", 
"displayName": "No Namespace Schema Location", "group": "advanced", "label": 
"advanced", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "To define the location of the namespaceless schema." },
-    "jaxbProviderProperties": { "index": 18, "kind": "attribute", 
"displayName": "Jaxb Provider Properties", "group": "advanced", "label": 
"advanced", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "Refers to a custom java.util.Map to lookup in the registry 
containing custom JAXB provider properties to be used with the JAXB 
marshaller." },
-    "contentTypeHeader": { "index": 19, "kind": "attribute", "displayName": 
"Content Type Header", "group": "common", "required": false, "type": "boolean", 
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": true, "description": "Whether the data format 
should set the Content-Type header with the type from the data format. For 
example application\/xml for data formats marshalling to XML, or 
application\/json for data formats marshall [...]
-    "accessExternalSchemaProtocols": { "index": 20, "kind": "attribute", 
"displayName": "Access External Schema Protocols", "group": "security", 
"label": "security", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "Only in use if schema validation has been enabled. Restrict 
access to the protocols specified for external reference set by the 
schemaLocation attribute, Import and Include element." }
+    "allowPartClassFromHeader": { "index": 14, "kind": "attribute", 
"displayName": "Allow Part Class From Header", "group": "advanced", "label": 
"advanced", "required": false, "type": "boolean", "javaType": 
"java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": false, "description": "Whether the CamelJaxbPartClass and 
CamelJaxbPartNamespace headers are used, when set, instead of the partClass and 
partNamespace options when marshalling and unmarshal [...]
+    "namespacePrefix": { "index": 15, "kind": "attribute", "displayName": 
"Namespace Prefix", "group": "advanced", "label": "advanced", "required": 
false, "type": "object", "javaType": "java.util.Map", "deprecated": false, 
"autowired": false, "secret": false, "description": "When marshalling using 
JAXB or SOAP then the JAXB implementation will automatically assign namespace 
prefixes, such as ns2, ns3, ns4 etc. To control this mapping, Camel allows you 
to refer to a map which contains the [...]
+    "xmlStreamWriterWrapper": { "index": 16, "kind": "attribute", 
"displayName": "Xml Stream Writer Wrapper", "group": "advanced", "label": 
"advanced", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "To use a custom xml stream writer." },
+    "schemaLocation": { "index": 17, "kind": "attribute", "displayName": 
"Schema Location", "group": "common", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "autowired": false, 
"secret": false, "description": "To define the location of the schema." },
+    "noNamespaceSchemaLocation": { "index": 18, "kind": "attribute", 
"displayName": "No Namespace Schema Location", "group": "advanced", "label": 
"advanced", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "To define the location of the namespaceless schema." },
+    "jaxbProviderProperties": { "index": 19, "kind": "attribute", 
"displayName": "Jaxb Provider Properties", "group": "advanced", "label": 
"advanced", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "Refers to a custom java.util.Map to lookup in the registry 
containing custom JAXB provider properties to be used with the JAXB 
marshaller." },
+    "contentTypeHeader": { "index": 20, "kind": "attribute", "displayName": 
"Content Type Header", "group": "common", "required": false, "type": "boolean", 
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": true, "description": "Whether the data format 
should set the Content-Type header with the type from the data format. For 
example application\/xml for data formats marshalling to XML, or 
application\/json for data formats marshall [...]
+    "accessExternalSchemaProtocols": { "index": 21, "kind": "attribute", 
"displayName": "Access External Schema Protocols", "group": "security", 
"label": "security", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "Only in use if schema validation has been enabled. Restrict 
access to the protocols specified for external reference set by the 
schemaLocation attribute, Import and Include element." }
   }
 }
diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
index 9f046e2ec875..1a566bbedccd 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
@@ -8861,6 +8861,17 @@ Name of class used for fragment parsing.
             <xs:documentation xml:lang="en">
 <![CDATA[
 XML namespace to use for fragment parsing.
+]]>
+            </xs:documentation>
+          </xs:annotation>
+        </xs:attribute>
+        <xs:attribute name="allowPartClassFromHeader" type="xs:string">
+          <xs:annotation>
+            <xs:documentation xml:lang="en">
+<![CDATA[
+Whether the CamelJaxbPartClass and CamelJaxbPartNamespace headers are used, 
when set, instead of the partClass and
+partNamespace options when marshalling and unmarshalling. Enable it only when 
the route sets these headers itself, not
+on routes that receive them from external systems. Default value: false
 ]]>
             </xs:documentation>
           </xs:annotation>
diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-xml-io.xsd
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-xml-io.xsd
index e99399e04af2..559a00804e0b 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-xml-io.xsd
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-xml-io.xsd
@@ -7983,6 +7983,17 @@ Name of class used for fragment parsing.
             <xs:documentation xml:lang="en">
 <![CDATA[
 XML namespace to use for fragment parsing.
+]]>
+            </xs:documentation>
+          </xs:annotation>
+        </xs:attribute>
+        <xs:attribute name="allowPartClassFromHeader" type="xs:string">
+          <xs:annotation>
+            <xs:documentation xml:lang="en">
+<![CDATA[
+Whether the CamelJaxbPartClass and CamelJaxbPartNamespace headers are used, 
when set, instead of the partClass and
+partNamespace options when marshalling and unmarshalling. Enable it only when 
the route sets these headers itself, not
+on routes that receive them from external systems. Default value: false
 ]]>
             </xs:documentation>
           </xs:annotation>
diff --git 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camelYamlDsl-model.json
 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camelYamlDsl-model.json
index 0e2a74f1d16c..2b267e110bc1 100644
--- 
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camelYamlDsl-model.json
+++ 
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camelYamlDsl-model.json
@@ -12076,6 +12076,17 @@
         "index" : 13,
         "group" : "advanced",
         "label" : "advanced"
+      }, {
+        "name" : "allowPartClassFromHeader",
+        "type" : "boolean",
+        "description" : "Whether the CamelJaxbPartClass and 
CamelJaxbPartNamespace headers are used, when set, instead of the partClass and 
partNamespace options when marshalling and unmarshalling. Enable it only when 
the route sets these headers itself, not on routes that receive them from 
external systems.",
+        "title" : "Allow Part Class From Header",
+        "default" : "false",
+        "displayName" : "Allow Part Class From Header",
+        "kind" : "attribute",
+        "index" : 14,
+        "group" : "advanced",
+        "label" : "advanced"
       }, {
         "name" : "namespacePrefix",
         "type" : "string",
@@ -12083,7 +12094,7 @@
         "title" : "Namespace Prefix",
         "displayName" : "Namespace Prefix",
         "kind" : "attribute",
-        "index" : 14,
+        "index" : 15,
         "group" : "advanced",
         "label" : "advanced"
       }, {
@@ -12093,7 +12104,7 @@
         "title" : "Xml Stream Writer Wrapper",
         "displayName" : "Xml Stream Writer Wrapper",
         "kind" : "attribute",
-        "index" : 15,
+        "index" : 16,
         "group" : "advanced",
         "label" : "advanced"
       }, {
@@ -12103,7 +12114,7 @@
         "title" : "Schema Location",
         "displayName" : "Schema Location",
         "kind" : "attribute",
-        "index" : 16,
+        "index" : 17,
         "group" : "common"
       }, {
         "name" : "noNamespaceSchemaLocation",
@@ -12112,7 +12123,7 @@
         "title" : "No Namespace Schema Location",
         "displayName" : "No Namespace Schema Location",
         "kind" : "attribute",
-        "index" : 17,
+        "index" : 18,
         "group" : "advanced",
         "label" : "advanced"
       }, {
@@ -12122,7 +12133,7 @@
         "title" : "Jaxb Provider Properties",
         "displayName" : "Jaxb Provider Properties",
         "kind" : "attribute",
-        "index" : 18,
+        "index" : 19,
         "group" : "advanced",
         "label" : "advanced"
       }, {
@@ -12133,7 +12144,7 @@
         "default" : "true",
         "displayName" : "Content Type Header",
         "kind" : "attribute",
-        "index" : 19,
+        "index" : 20,
         "group" : "common"
       }, {
         "name" : "accessExternalSchemaProtocols",
@@ -12142,7 +12153,7 @@
         "title" : "Access External Schema Protocols",
         "displayName" : "Access External Schema Protocols",
         "kind" : "attribute",
-        "index" : 20,
+        "index" : 21,
         "group" : "security",
         "label" : "security"
       } ]
diff --git 
a/components/camel-jaxb/src/generated/java/org/apache/camel/converter/jaxb/JaxbDataFormatConfigurer.java
 
b/components/camel-jaxb/src/generated/java/org/apache/camel/converter/jaxb/JaxbDataFormatConfigurer.java
index 82d228749d68..92829bdc5b76 100644
--- 
a/components/camel-jaxb/src/generated/java/org/apache/camel/converter/jaxb/JaxbDataFormatConfigurer.java
+++ 
b/components/camel-jaxb/src/generated/java/org/apache/camel/converter/jaxb/JaxbDataFormatConfigurer.java
@@ -23,6 +23,7 @@ public class JaxbDataFormatConfigurer extends 
org.apache.camel.support.component
     static {
         Map<String, Object> map = new CaseInsensitiveMap();
         map.put("AccessExternalSchemaProtocols", java.lang.String.class);
+        map.put("AllowPartClassFromHeader", boolean.class);
         map.put("ContentTypeHeader", boolean.class);
         map.put("ContextPath", java.lang.String.class);
         map.put("ContextPathIsClassName", boolean.class);
@@ -51,6 +52,8 @@ public class JaxbDataFormatConfigurer extends 
org.apache.camel.support.component
         switch (ignoreCase ? name.toLowerCase() : name) {
         case "accessexternalschemaprotocols":
         case "accessExternalSchemaProtocols": 
target.setAccessExternalSchemaProtocols(property(camelContext, 
java.lang.String.class, value)); return true;
+        case "allowpartclassfromheader":
+        case "allowPartClassFromHeader": 
target.setAllowPartClassFromHeader(property(camelContext, boolean.class, 
value)); return true;
         case "contenttypeheader":
         case "contentTypeHeader": 
target.setContentTypeHeader(property(camelContext, boolean.class, value)); 
return true;
         case "contextpath":
@@ -100,6 +103,8 @@ public class JaxbDataFormatConfigurer extends 
org.apache.camel.support.component
         switch (ignoreCase ? name.toLowerCase() : name) {
         case "accessexternalschemaprotocols":
         case "accessExternalSchemaProtocols": return java.lang.String.class;
+        case "allowpartclassfromheader":
+        case "allowPartClassFromHeader": return boolean.class;
         case "contenttypeheader":
         case "contentTypeHeader": return boolean.class;
         case "contextpath":
@@ -145,6 +150,8 @@ public class JaxbDataFormatConfigurer extends 
org.apache.camel.support.component
         switch (ignoreCase ? name.toLowerCase() : name) {
         case "accessexternalschemaprotocols":
         case "accessExternalSchemaProtocols": return 
target.getAccessExternalSchemaProtocols();
+        case "allowpartclassfromheader":
+        case "allowPartClassFromHeader": return 
target.isAllowPartClassFromHeader();
         case "contenttypeheader":
         case "contentTypeHeader": return target.isContentTypeHeader();
         case "contextpath":
diff --git 
a/components/camel-jaxb/src/generated/resources/META-INF/org/apache/camel/converter/jaxb/jaxb.json
 
b/components/camel-jaxb/src/generated/resources/META-INF/org/apache/camel/converter/jaxb/jaxb.json
index 2a2e425cabd9..1a624c0bfbc5 100644
--- 
a/components/camel-jaxb/src/generated/resources/META-INF/org/apache/camel/converter/jaxb/jaxb.json
+++ 
b/components/camel-jaxb/src/generated/resources/META-INF/org/apache/camel/converter/jaxb/jaxb.json
@@ -30,12 +30,13 @@
     "fragment": { "index": 11, "kind": "attribute", "displayName": "Fragment", 
"group": "advanced", "label": "advanced", "required": false, "type": "boolean", 
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": false, "description": "To turn on marshalling 
XML fragment trees. This is useful when generated code does not have 
XmlRootElement annotation and you need to unmarshall only part of the tree." },
     "partClass": { "index": 12, "kind": "attribute", "displayName": "Part 
Class", "group": "advanced", "label": "advanced", "required": false, "type": 
"string", "javaType": "java.lang.String", "deprecated": false, "autowired": 
false, "secret": false, "description": "Name of class used for fragment 
parsing." },
     "partNamespace": { "index": 13, "kind": "attribute", "displayName": "Part 
Namespace", "group": "advanced", "label": "advanced", "required": false, 
"type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "description": "XML namespace to use for 
fragment parsing." },
-    "namespacePrefix": { "index": 14, "kind": "attribute", "displayName": 
"Namespace Prefix", "group": "advanced", "label": "advanced", "required": 
false, "type": "object", "javaType": "java.util.Map", "deprecated": false, 
"autowired": false, "secret": false, "description": "When marshalling using 
JAXB or SOAP then the JAXB implementation will automatically assign namespace 
prefixes, such as ns2, ns3, ns4 etc. To control this mapping, Camel allows you 
to refer to a map which contains the [...]
-    "xmlStreamWriterWrapper": { "index": 15, "kind": "attribute", 
"displayName": "Xml Stream Writer Wrapper", "group": "advanced", "label": 
"advanced", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "To use a custom xml stream writer." },
-    "schemaLocation": { "index": 16, "kind": "attribute", "displayName": 
"Schema Location", "group": "common", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "autowired": false, 
"secret": false, "description": "To define the location of the schema." },
-    "noNamespaceSchemaLocation": { "index": 17, "kind": "attribute", 
"displayName": "No Namespace Schema Location", "group": "advanced", "label": 
"advanced", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "To define the location of the namespaceless schema." },
-    "jaxbProviderProperties": { "index": 18, "kind": "attribute", 
"displayName": "Jaxb Provider Properties", "group": "advanced", "label": 
"advanced", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "Refers to a custom java.util.Map to lookup in the registry 
containing custom JAXB provider properties to be used with the JAXB 
marshaller." },
-    "contentTypeHeader": { "index": 19, "kind": "attribute", "displayName": 
"Content Type Header", "group": "common", "required": false, "type": "boolean", 
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": true, "description": "Whether the data format 
should set the Content-Type header with the type from the data format. For 
example application\/xml for data formats marshalling to XML, or 
application\/json for data formats marshall [...]
-    "accessExternalSchemaProtocols": { "index": 20, "kind": "attribute", 
"displayName": "Access External Schema Protocols", "group": "security", 
"label": "security", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "Only in use if schema validation has been enabled. Restrict 
access to the protocols specified for external reference set by the 
schemaLocation attribute, Import and Include element." }
+    "allowPartClassFromHeader": { "index": 14, "kind": "attribute", 
"displayName": "Allow Part Class From Header", "group": "advanced", "label": 
"advanced", "required": false, "type": "boolean", "javaType": 
"java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": false, "description": "Whether the CamelJaxbPartClass and 
CamelJaxbPartNamespace headers are used, when set, instead of the partClass and 
partNamespace options when marshalling and unmarshal [...]
+    "namespacePrefix": { "index": 15, "kind": "attribute", "displayName": 
"Namespace Prefix", "group": "advanced", "label": "advanced", "required": 
false, "type": "object", "javaType": "java.util.Map", "deprecated": false, 
"autowired": false, "secret": false, "description": "When marshalling using 
JAXB or SOAP then the JAXB implementation will automatically assign namespace 
prefixes, such as ns2, ns3, ns4 etc. To control this mapping, Camel allows you 
to refer to a map which contains the [...]
+    "xmlStreamWriterWrapper": { "index": 16, "kind": "attribute", 
"displayName": "Xml Stream Writer Wrapper", "group": "advanced", "label": 
"advanced", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "To use a custom xml stream writer." },
+    "schemaLocation": { "index": 17, "kind": "attribute", "displayName": 
"Schema Location", "group": "common", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "autowired": false, 
"secret": false, "description": "To define the location of the schema." },
+    "noNamespaceSchemaLocation": { "index": 18, "kind": "attribute", 
"displayName": "No Namespace Schema Location", "group": "advanced", "label": 
"advanced", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "To define the location of the namespaceless schema." },
+    "jaxbProviderProperties": { "index": 19, "kind": "attribute", 
"displayName": "Jaxb Provider Properties", "group": "advanced", "label": 
"advanced", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "Refers to a custom java.util.Map to lookup in the registry 
containing custom JAXB provider properties to be used with the JAXB 
marshaller." },
+    "contentTypeHeader": { "index": 20, "kind": "attribute", "displayName": 
"Content Type Header", "group": "common", "required": false, "type": "boolean", 
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": true, "description": "Whether the data format 
should set the Content-Type header with the type from the data format. For 
example application\/xml for data formats marshalling to XML, or 
application\/json for data formats marshall [...]
+    "accessExternalSchemaProtocols": { "index": 21, "kind": "attribute", 
"displayName": "Access External Schema Protocols", "group": "security", 
"label": "security", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "Only in use if schema validation has been enabled. Restrict 
access to the protocols specified for external reference set by the 
schemaLocation attribute, Import and Include element." }
   }
 }
diff --git a/components/camel-jaxb/src/main/docs/jaxb-dataformat.adoc 
b/components/camel-jaxb/src/main/docs/jaxb-dataformat.adoc
index 3a37dcbd991c..0a4c18f9693b 100644
--- a/components/camel-jaxb/src/main/docs/jaxb-dataformat.adoc
+++ b/components/camel-jaxb/src/main/docs/jaxb-dataformat.adoc
@@ -96,23 +96,35 @@ need to unmarshall only part of the tree.
 
 In that case, you can use partial unmarshalling. To enable this
 behavior, you need set property `partClass` on the `JaxbDataFormat`. Camel 
will pass this class
-to the JAXB unmarshaller. If `CamelJaxbPartClass` is set as
-one of the exchange headers, its value is used to override the `partClass` 
property
-on the `JaxbDataFormat`.
+to the JAXB unmarshaller.
 
 For marshalling you have to add the `partNamespace` attribute with the `QName` 
of
 the destination namespace.
 
-If `CamelJaxbPartNamespace` is set as
-one of the exchange headers, its value is used to override the `partNamespace` 
property
-on the `JaxbDataFormat`.
+==== Choosing the part class with headers
+
+To choose the part class and namespace per message, enable the 
`allowPartClassFromHeader` option
+(default `false`). Then the following exchange headers, when set, are used 
instead of the
+`partClass` and `partNamespace` options on the `JaxbDataFormat`:
+
+* `CamelJaxbPartClass`: the class name used instead of `partClass`, when 
marshalling and unmarshalling.
+* `CamelJaxbPartNamespace`: the namespace used instead of `partNamespace`, 
when marshalling.
+
+When `allowPartClassFromHeader` is `false`, these headers are ignored.
 
 While setting `partNamespace` through the `CamelJaxbPartNamespace` header, 
please
 note that you need to specify its value in the format 
`\{namespaceUri\}localPart`, as per the example below.
 
 [source,java]
 ----
-.setHeader("CamelJaxbPartNamespace", 
constant("{http://www.camel.apache.org/jaxb/example/address/1}address";));
+JaxbDataFormat jaxb = new JaxbDataFormat("com.mycompany.model");
+jaxb.setAllowPartClassFromHeader(true);
+
+from("direct:start")
+    .setHeader("CamelJaxbPartClass", constant("com.mycompany.model.Address"))
+    .setHeader("CamelJaxbPartNamespace", 
constant("{http://www.camel.apache.org/jaxb/example/address/1}address";))
+    .marshal(jaxb)
+    .to("mock:result");
 ----
 
 === Fragment
diff --git 
a/components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/JaxbDataFormat.java
 
b/components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/JaxbDataFormat.java
index 6ef18ca80983..c6dfa101989f 100644
--- 
a/components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/JaxbDataFormat.java
+++ 
b/components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/JaxbDataFormat.java
@@ -99,6 +99,7 @@ public class JaxbDataFormat extends ServiceSupport
     // partial support
     private QName partNamespace;
     private Class<?> partClass;
+    private boolean allowPartClassFromHeader;
     private Map<String, String> namespacePrefix;
     private JaxbNamespacePrefixMapper namespacePrefixMapper;
     private JaxbXmlStreamWriterWrapper xmlStreamWriterWrapper;
@@ -189,8 +190,12 @@ public class JaxbDataFormat extends ServiceSupport
 
         Object element = graph;
         QName partNamespaceOnDataFormat = getPartNamespace();
-        String partClassFromHeader = 
exchange.getIn().getHeader(JaxbConstants.JAXB_PART_CLASS, String.class);
-        String partNamespaceFromHeader = 
exchange.getIn().getHeader(JaxbConstants.JAXB_PART_NAMESPACE, String.class);
+        String partClassFromHeader = null;
+        String partNamespaceFromHeader = null;
+        if (allowPartClassFromHeader) {
+            partClassFromHeader = 
exchange.getIn().getHeader(JaxbConstants.JAXB_PART_CLASS, String.class);
+            partNamespaceFromHeader = 
exchange.getIn().getHeader(JaxbConstants.JAXB_PART_NAMESPACE, String.class);
+        }
         if ((partClass != null || partClassFromHeader != null)
                 && (partNamespaceOnDataFormat != null || 
partNamespaceFromHeader != null)) {
             element = toElement(graph, partClassFromHeader, 
partNamespaceFromHeader, partNamespaceOnDataFormat);
@@ -331,7 +336,8 @@ public class JaxbDataFormat extends ServiceSupport
                     xmlReader = typeConverter.convertTo(XMLStreamReader.class, 
exchange, is);
                 }
             }
-            String partClassFromHeader = 
exchange.getIn().getHeader(JaxbConstants.JAXB_PART_CLASS, String.class);
+            String partClassFromHeader = allowPartClassFromHeader
+                    ? 
exchange.getIn().getHeader(JaxbConstants.JAXB_PART_CLASS, String.class) : null;
             Class<?> effectivePartClass = partClass;
             if (partClassFromHeader != null) {
                 try {
@@ -495,6 +501,18 @@ public class JaxbDataFormat extends ServiceSupport
         this.partClass = partClass;
     }
 
+    public boolean isAllowPartClassFromHeader() {
+        return allowPartClassFromHeader;
+    }
+
+    /**
+     * Whether the {@link JaxbConstants#JAXB_PART_CLASS} and {@link 
JaxbConstants#JAXB_PART_NAMESPACE} headers are used,
+     * when set, instead of the partClass and partNamespace options when 
marshalling and unmarshalling.
+     */
+    public void setAllowPartClassFromHeader(boolean allowPartClassFromHeader) {
+        this.allowPartClassFromHeader = allowPartClassFromHeader;
+    }
+
     public Map<String, String> getNamespacePrefix() {
         return namespacePrefix;
     }
diff --git 
a/components/camel-jaxb/src/test/java/org/apache/camel/converter/jaxb/JaxbDataFormatPartClassHeaderTest.java
 
b/components/camel-jaxb/src/test/java/org/apache/camel/converter/jaxb/JaxbDataFormatPartClassHeaderTest.java
index b2621ca746e9..d873054607c6 100644
--- 
a/components/camel-jaxb/src/test/java/org/apache/camel/converter/jaxb/JaxbDataFormatPartClassHeaderTest.java
+++ 
b/components/camel-jaxb/src/test/java/org/apache/camel/converter/jaxb/JaxbDataFormatPartClassHeaderTest.java
@@ -75,6 +75,7 @@ public class JaxbDataFormatPartClassHeaderTest extends 
CamelTestSupport {
                 jaxbDataFormat.setPartNamespace(
                         new 
QName("http://www.camel.apache.org/jaxb/example/address/123";, 
"addressToBeOverriden"));
                 jaxbDataFormat.setPrettyPrint(true);
+                jaxbDataFormat.setAllowPartClassFromHeader(true);
 
                 from("direct:marshall")
                         .setHeader(JaxbConstants.JAXB_PART_CLASS, 
simple("org.apache.camel.example.Address"))
diff --git 
a/components/camel-jaxb/src/test/java/org/apache/camel/converter/jaxb/JaxbPartClassHeaderOptionTest.java
 
b/components/camel-jaxb/src/test/java/org/apache/camel/converter/jaxb/JaxbPartClassHeaderOptionTest.java
new file mode 100644
index 000000000000..a81639e7a281
--- /dev/null
+++ 
b/components/camel-jaxb/src/test/java/org/apache/camel/converter/jaxb/JaxbPartClassHeaderOptionTest.java
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.converter.jaxb;
+
+import javax.xml.namespace.QName;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.example.Address;
+import org.apache.camel.example.Partial;
+import org.apache.camel.example.PurchaseOrder;
+import org.apache.camel.test.junit6.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * The CamelJaxbPartClass and CamelJaxbPartNamespace headers are used only 
when allowPartClassFromHeader is enabled.
+ */
+public class JaxbPartClassHeaderOptionTest extends CamelTestSupport {
+
+    private static final String ADDRESS_NAMESPACE = 
"http://www.camel.apache.org/jaxb/example/address/1";;
+
+    private static final String PARTIAL_XML = "<partial 
name=\"foo\"><location>Here</location></partial>";
+
+    private static final String PURCHASE_ORDER_XML = "<purchaseOrder 
name=\"foo\" price=\"1.23\" amount=\"2.0\"/>";
+
+    @Test
+    public void partClassHeaderIgnoredByDefault() {
+        Object body = template.requestBodyAndHeader("direct:unmarshal", 
PARTIAL_XML,
+                JaxbConstants.JAXB_PART_CLASS, Address.class.getName());
+
+        Partial partial = assertInstanceOf(Partial.class, body);
+        assertEquals("foo", partial.getName());
+        assertEquals("Here", partial.getLocation());
+    }
+
+    @Test
+    public void partClassHeaderUsedWhenAllowed() {
+        Object body = template.requestBodyAndHeader("direct:unmarshalAllowed", 
PARTIAL_XML,
+                JaxbConstants.JAXB_PART_CLASS, Address.class.getName());
+
+        assertInstanceOf(Address.class, body);
+    }
+
+    @Test
+    public void partClassHeaderAloneDoesNotEnablePartialUnmarshalByDefault() {
+        Object body = 
template.requestBodyAndHeader("direct:unmarshalNoPartClass", PURCHASE_ORDER_XML,
+                JaxbConstants.JAXB_PART_CLASS, Address.class.getName());
+
+        PurchaseOrder order = assertInstanceOf(PurchaseOrder.class, body);
+        assertEquals("foo", order.getName());
+    }
+
+    @Test
+    public void partNamespaceHeaderIgnoredByDefaultOnMarshal() {
+        String xml = template.requestBodyAndHeader("direct:marshal", 
createAddress(),
+                JaxbConstants.JAXB_PART_NAMESPACE, "{" + ADDRESS_NAMESPACE + 
"}shippingAddress", String.class);
+
+        assertTrue(xml.contains("<address:address"), xml);
+        assertFalse(xml.contains("shippingAddress"), xml);
+    }
+
+    @Test
+    public void partNamespaceHeaderUsedWhenAllowed() {
+        String xml = template.requestBodyAndHeader("direct:marshalAllowed", 
createAddress(),
+                JaxbConstants.JAXB_PART_NAMESPACE, "{" + ADDRESS_NAMESPACE + 
"}shippingAddress", String.class);
+
+        assertTrue(xml.contains("<address:shippingAddress"), xml);
+    }
+
+    private static Address createAddress() {
+        Address address = new Address();
+        address.setStreet("Main Street");
+        address.setStreetNumber("3a");
+        address.setZip("65843");
+        address.setCity("Sulzbach");
+        return address;
+    }
+
+    private static JaxbDataFormat createDataFormat(Class<?> partClass, boolean 
allowPartClassFromHeader) {
+        JaxbDataFormat jaxb = new JaxbDataFormat();
+        jaxb.setContextPath(Address.class.getPackage().getName());
+        jaxb.setPartClass(partClass);
+        jaxb.setAllowPartClassFromHeader(allowPartClassFromHeader);
+        return jaxb;
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            @Override
+            public void configure() {
+                
from("direct:unmarshal").unmarshal(createDataFormat(Partial.class, false));
+                
from("direct:unmarshalAllowed").unmarshal(createDataFormat(Partial.class, 
true));
+                
from("direct:unmarshalNoPartClass").unmarshal(createDataFormat(null, false));
+
+                JaxbDataFormat marshal = createDataFormat(Address.class, 
false);
+                marshal.setPartNamespace(new QName(ADDRESS_NAMESPACE, 
"address"));
+                from("direct:marshal").marshal(marshal);
+
+                JaxbDataFormat marshalAllowed = 
createDataFormat(Address.class, true);
+                marshalAllowed.setPartNamespace(new QName(ADDRESS_NAMESPACE, 
"address"));
+                from("direct:marshalAllowed").marshal(marshalAllowed);
+            }
+        };
+    }
+}
diff --git 
a/components/camel-jaxb/src/test/java/org/apache/camel/converter/jaxb/JaxbPartClassHeaderStatePollutionTest.java
 
b/components/camel-jaxb/src/test/java/org/apache/camel/converter/jaxb/JaxbPartClassHeaderStatePollutionTest.java
index c7cc52270011..6b5030e39019 100644
--- 
a/components/camel-jaxb/src/test/java/org/apache/camel/converter/jaxb/JaxbPartClassHeaderStatePollutionTest.java
+++ 
b/components/camel-jaxb/src/test/java/org/apache/camel/converter/jaxb/JaxbPartClassHeaderStatePollutionTest.java
@@ -122,6 +122,7 @@ public class JaxbPartClassHeaderStatePollutionTest extends 
CamelTestSupport {
             public void configure() {
                 JaxbDataFormat jaxb = new JaxbDataFormat();
                 jaxb.setContextPath("org.apache.camel.example");
+                jaxb.setAllowPartClassFromHeader(true);
 
                 from("direct:unmarshal")
                         .unmarshal(jaxb)
@@ -130,6 +131,7 @@ public class JaxbPartClassHeaderStatePollutionTest extends 
CamelTestSupport {
                 JaxbDataFormat jaxbMarshal = new JaxbDataFormat();
                 jaxbMarshal.setContextPath("org.apache.camel.example");
                 jaxbMarshal.setPrettyPrint(true);
+                jaxbMarshal.setAllowPartClassFromHeader(true);
 
                 from("direct:marshal")
                         .marshal(jaxbMarshal)
diff --git 
a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/rest/RestJettyNoContentRestConfigTest.java
 
b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/rest/RestJettyNoContentRestConfigTest.java
index ce738b6b5d71..1bcc63b7f82d 100644
--- 
a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/rest/RestJettyNoContentRestConfigTest.java
+++ 
b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/rest/RestJettyNoContentRestConfigTest.java
@@ -142,7 +142,8 @@ public class RestJettyNoContentRestConfigTest extends 
BaseJettyTest {
             @Override
             public void configure() {
                 
restConfiguration().component("jetty").host("localhost").port(getPort())
-                        
.bindingMode(RestBindingMode.auto).enableNoContentResponse(true);
+                        
.bindingMode(RestBindingMode.auto).enableNoContentResponse(true)
+                        
.dataFormatProperty("xml.out.allowPartClassFromHeader", "true");
 
                 rest("/v1/empty")
                         .get("/country").to("direct:v1country")
diff --git 
a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/rest/RestJettyNoContentTest.java
 
b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/rest/RestJettyNoContentTest.java
index 22d8d3dd151d..1e0fe219c56d 100644
--- 
a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/rest/RestJettyNoContentTest.java
+++ 
b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/rest/RestJettyNoContentTest.java
@@ -142,7 +142,8 @@ public class RestJettyNoContentTest extends BaseJettyTest {
             @Override
             public void configure() {
                 
restConfiguration().component("jetty").host("localhost").port(getPort())
-                        .bindingMode(RestBindingMode.auto);
+                        .bindingMode(RestBindingMode.auto)
+                        
.dataFormatProperty("xml.out.allowPartClassFromHeader", "true");
 
                 rest("/v1/empty")
                         .get("/country").to("direct:v1country")
diff --git 
a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletNoContentRestConfigTest.java
 
b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletNoContentRestConfigTest.java
index 702810843227..25ab0eba82f5 100644
--- 
a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletNoContentRestConfigTest.java
+++ 
b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletNoContentRestConfigTest.java
@@ -108,7 +108,8 @@ public class RestServletNoContentRestConfigTest extends 
ServletCamelRouterTestSu
             @Override
             public void configure() {
                 restConfiguration().component("servlet").host("localhost")
-                        
.bindingMode(RestBindingMode.auto).enableNoContentResponse(true);
+                        
.bindingMode(RestBindingMode.auto).enableNoContentResponse(true)
+                        
.dataFormatProperty("xml.out.allowPartClassFromHeader", "true");
 
                 rest("/v1/empty")
                         .get("/country").to("direct:v1country")
diff --git 
a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletNoContentTest.java
 
b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletNoContentTest.java
index 2efb75e38337..e27a84be406b 100644
--- 
a/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletNoContentTest.java
+++ 
b/components/camel-servlet/src/test/java/org/apache/camel/component/servlet/rest/RestServletNoContentTest.java
@@ -107,7 +107,8 @@ public class RestServletNoContentTest extends 
ServletCamelRouterTestSupport {
             @Override
             public void configure() {
                 restConfiguration().component("servlet").host("localhost")
-                        .bindingMode(RestBindingMode.auto);
+                        .bindingMode(RestBindingMode.auto)
+                        
.dataFormatProperty("xml.out.allowPartClassFromHeader", "true");
 
                 rest("/v1/empty")
                         .get("/country").to("direct:v1country")
diff --git 
a/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapUnMarshalTest.java
 
b/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapUnMarshalTest.java
index 56123d74cf09..e790694fb7a7 100644
--- 
a/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapUnMarshalTest.java
+++ 
b/components/camel-soap/src/test/java/org/apache/camel/dataformat/soap/SoapUnMarshalTest.java
@@ -18,6 +18,7 @@ package org.apache.camel.dataformat.soap;
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.Map;
 
 import jakarta.xml.ws.soap.SOAPFaultException;
 
@@ -28,6 +29,7 @@ import org.apache.camel.Produce;
 import org.apache.camel.ProducerTemplate;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.converter.jaxb.JaxbConstants;
 import org.apache.camel.test.junit6.CamelTestSupport;
 import org.junit.jupiter.api.Test;
 
@@ -60,6 +62,19 @@ public class SoapUnMarshalTest extends CamelTestSupport {
         assertEquals("Smith", request.getName());
     }
 
+    @Test
+    public void testUnMarshalSoapIgnoresPartClassHeaders() throws IOException, 
InterruptedException {
+        resultEndpoint.expectedMessageCount(1);
+        InputStream in = this.getClass().getResourceAsStream("request.xml");
+        producer.sendBodyAndHeaders(in, Map.of(
+                JaxbConstants.JAXB_PART_CLASS, 
GetCustomersByName.class.getName(),
+                JaxbConstants.JAXB_PART_NAMESPACE, 
"{http://customerservice.example.com/}getCustomersByName";));
+        resultEndpoint.assertIsSatisfied();
+        Object body = resultEndpoint.getExchanges().get(0).getIn().getBody();
+        assertEquals(GetCustomersByName.class, body.getClass());
+        assertEquals("Smith", ((GetCustomersByName) body).getName());
+    }
+
     @Test
     public void testUnMarshalSoapFaultWithoutDetail() throws IOException, 
InterruptedException {
         InputStream in = 
this.getClass().getResourceAsStream("faultWithoutDetail.xml");
diff --git 
a/core/camel-core-model/src/generated/resources/META-INF/org/apache/camel/model/dataformat/jaxb.json
 
b/core/camel-core-model/src/generated/resources/META-INF/org/apache/camel/model/dataformat/jaxb.json
index 1e87633c772a..8daabff5a2ed 100644
--- 
a/core/camel-core-model/src/generated/resources/META-INF/org/apache/camel/model/dataformat/jaxb.json
+++ 
b/core/camel-core-model/src/generated/resources/META-INF/org/apache/camel/model/dataformat/jaxb.json
@@ -27,12 +27,13 @@
     "fragment": { "index": 11, "kind": "attribute", "displayName": "Fragment", 
"group": "advanced", "label": "advanced", "required": false, "type": "boolean", 
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": false, "description": "To turn on marshalling 
XML fragment trees. This is useful when generated code does not have 
XmlRootElement annotation and you need to unmarshall only part of the tree." },
     "partClass": { "index": 12, "kind": "attribute", "displayName": "Part 
Class", "group": "advanced", "label": "advanced", "required": false, "type": 
"string", "javaType": "java.lang.String", "deprecated": false, "autowired": 
false, "secret": false, "description": "Name of class used for fragment 
parsing." },
     "partNamespace": { "index": 13, "kind": "attribute", "displayName": "Part 
Namespace", "group": "advanced", "label": "advanced", "required": false, 
"type": "string", "javaType": "java.lang.String", "deprecated": false, 
"autowired": false, "secret": false, "description": "XML namespace to use for 
fragment parsing." },
-    "namespacePrefix": { "index": 14, "kind": "attribute", "displayName": 
"Namespace Prefix", "group": "advanced", "label": "advanced", "required": 
false, "type": "object", "javaType": "java.util.Map", "deprecated": false, 
"autowired": false, "secret": false, "description": "When marshalling using 
JAXB or SOAP then the JAXB implementation will automatically assign namespace 
prefixes, such as ns2, ns3, ns4 etc. To control this mapping, Camel allows you 
to refer to a map which contains the [...]
-    "xmlStreamWriterWrapper": { "index": 15, "kind": "attribute", 
"displayName": "Xml Stream Writer Wrapper", "group": "advanced", "label": 
"advanced", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "To use a custom xml stream writer." },
-    "schemaLocation": { "index": 16, "kind": "attribute", "displayName": 
"Schema Location", "group": "common", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "autowired": false, 
"secret": false, "description": "To define the location of the schema." },
-    "noNamespaceSchemaLocation": { "index": 17, "kind": "attribute", 
"displayName": "No Namespace Schema Location", "group": "advanced", "label": 
"advanced", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "To define the location of the namespaceless schema." },
-    "jaxbProviderProperties": { "index": 18, "kind": "attribute", 
"displayName": "Jaxb Provider Properties", "group": "advanced", "label": 
"advanced", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "Refers to a custom java.util.Map to lookup in the registry 
containing custom JAXB provider properties to be used with the JAXB 
marshaller." },
-    "contentTypeHeader": { "index": 19, "kind": "attribute", "displayName": 
"Content Type Header", "group": "common", "required": false, "type": "boolean", 
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": true, "description": "Whether the data format 
should set the Content-Type header with the type from the data format. For 
example application\/xml for data formats marshalling to XML, or 
application\/json for data formats marshall [...]
-    "accessExternalSchemaProtocols": { "index": 20, "kind": "attribute", 
"displayName": "Access External Schema Protocols", "group": "security", 
"label": "security", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "Only in use if schema validation has been enabled. Restrict 
access to the protocols specified for external reference set by the 
schemaLocation attribute, Import and Include element." }
+    "allowPartClassFromHeader": { "index": 14, "kind": "attribute", 
"displayName": "Allow Part Class From Header", "group": "advanced", "label": 
"advanced", "required": false, "type": "boolean", "javaType": 
"java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": false, "description": "Whether the CamelJaxbPartClass and 
CamelJaxbPartNamespace headers are used, when set, instead of the partClass and 
partNamespace options when marshalling and unmarshal [...]
+    "namespacePrefix": { "index": 15, "kind": "attribute", "displayName": 
"Namespace Prefix", "group": "advanced", "label": "advanced", "required": 
false, "type": "object", "javaType": "java.util.Map", "deprecated": false, 
"autowired": false, "secret": false, "description": "When marshalling using 
JAXB or SOAP then the JAXB implementation will automatically assign namespace 
prefixes, such as ns2, ns3, ns4 etc. To control this mapping, Camel allows you 
to refer to a map which contains the [...]
+    "xmlStreamWriterWrapper": { "index": 16, "kind": "attribute", 
"displayName": "Xml Stream Writer Wrapper", "group": "advanced", "label": 
"advanced", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "To use a custom xml stream writer." },
+    "schemaLocation": { "index": 17, "kind": "attribute", "displayName": 
"Schema Location", "group": "common", "required": false, "type": "string", 
"javaType": "java.lang.String", "deprecated": false, "autowired": false, 
"secret": false, "description": "To define the location of the schema." },
+    "noNamespaceSchemaLocation": { "index": 18, "kind": "attribute", 
"displayName": "No Namespace Schema Location", "group": "advanced", "label": 
"advanced", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "To define the location of the namespaceless schema." },
+    "jaxbProviderProperties": { "index": 19, "kind": "attribute", 
"displayName": "Jaxb Provider Properties", "group": "advanced", "label": 
"advanced", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "Refers to a custom java.util.Map to lookup in the registry 
containing custom JAXB provider properties to be used with the JAXB 
marshaller." },
+    "contentTypeHeader": { "index": 20, "kind": "attribute", "displayName": 
"Content Type Header", "group": "common", "required": false, "type": "boolean", 
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": true, "description": "Whether the data format 
should set the Content-Type header with the type from the data format. For 
example application\/xml for data formats marshalling to XML, or 
application\/json for data formats marshall [...]
+    "accessExternalSchemaProtocols": { "index": 21, "kind": "attribute", 
"displayName": "Access External Schema Protocols", "group": "security", 
"label": "security", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "autowired": false, "secret": false, 
"description": "Only in use if schema validation has been enabled. Restrict 
access to the protocols specified for external reference set by the 
schemaLocation attribute, Import and Include element." }
   }
 }
diff --git 
a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/JaxbDataFormat.java
 
b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/JaxbDataFormat.java
index 4bb5e7abea47..4dc319c65084 100644
--- 
a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/JaxbDataFormat.java
+++ 
b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/JaxbDataFormat.java
@@ -88,6 +88,13 @@ public class JaxbDataFormat extends DataFormatDefinition 
implements ContentTypeH
     @Metadata(label = "advanced", description = "XML namespace to use for 
fragment parsing.")
     private String partNamespace;
     @XmlAttribute
+    @Metadata(label = "advanced", javaType = "java.lang.Boolean",
+              description = "Whether the CamelJaxbPartClass and 
CamelJaxbPartNamespace headers are used, when set, instead of"
+                            + " the partClass and partNamespace options when 
marshalling and unmarshalling."
+                            + " Enable it only when the route sets these 
headers itself, not on routes that receive them from"
+                            + " external systems.")
+    private String allowPartClassFromHeader;
+    @XmlAttribute
     @Metadata(label = "advanced", javaType = "java.util.Map",
               description = "When marshalling using JAXB or SOAP then the JAXB 
implementation will automatically assign namespace prefixes,"
                             + " such as ns2, ns3, ns4 etc. To control this 
mapping, Camel allows you to refer to a map which contains the desired 
mapping.")
@@ -135,6 +142,7 @@ public class JaxbDataFormat extends DataFormatDefinition 
implements ContentTypeH
         this.fragment = source.fragment;
         this.partClass = source.partClass;
         this.partNamespace = source.partNamespace;
+        this.allowPartClassFromHeader = source.allowPartClassFromHeader;
         this.namespacePrefix = source.namespacePrefix;
         this.xmlStreamWriterWrapper = source.xmlStreamWriterWrapper;
         this.schemaLocation = source.schemaLocation;
@@ -164,6 +172,7 @@ public class JaxbDataFormat extends DataFormatDefinition 
implements ContentTypeH
         this.fragment = builder.fragment;
         this.partClass = builder.partClass;
         this.partNamespace = builder.partNamespace;
+        this.allowPartClassFromHeader = builder.allowPartClassFromHeader;
         this.namespacePrefix = builder.namespacePrefix;
         this.xmlStreamWriterWrapper = builder.xmlStreamWriterWrapper;
         this.schemaLocation = builder.schemaLocation;
@@ -282,6 +291,14 @@ public class JaxbDataFormat extends DataFormatDefinition 
implements ContentTypeH
         this.partNamespace = partNamespace;
     }
 
+    public String getAllowPartClassFromHeader() {
+        return allowPartClassFromHeader;
+    }
+
+    public void setAllowPartClassFromHeader(String allowPartClassFromHeader) {
+        this.allowPartClassFromHeader = allowPartClassFromHeader;
+    }
+
     public String getNamespacePrefix() {
         return namespacePrefix;
     }
@@ -357,6 +374,7 @@ public class JaxbDataFormat extends DataFormatDefinition 
implements ContentTypeH
         private String fragment;
         private String partClass;
         private String partNamespace;
+        private String allowPartClassFromHeader;
         private String namespacePrefix;
         private String xmlStreamWriterWrapper;
         private String schemaLocation;
@@ -560,6 +578,26 @@ public class JaxbDataFormat extends DataFormatDefinition 
implements ContentTypeH
             return this;
         }
 
+        /**
+         * Whether the CamelJaxbPartClass and CamelJaxbPartNamespace headers 
are used, when set, instead of the
+         * partClass and partNamespace options when marshalling and 
unmarshalling. Enable it only when the route sets
+         * these headers itself, not on routes that receive them from external 
systems.
+         */
+        public Builder allowPartClassFromHeader(String 
allowPartClassFromHeader) {
+            this.allowPartClassFromHeader = allowPartClassFromHeader;
+            return this;
+        }
+
+        /**
+         * Whether the CamelJaxbPartClass and CamelJaxbPartNamespace headers 
are used, when set, instead of the
+         * partClass and partNamespace options when marshalling and 
unmarshalling. Enable it only when the route sets
+         * these headers itself, not on routes that receive them from external 
systems.
+         */
+        public Builder allowPartClassFromHeader(boolean 
allowPartClassFromHeader) {
+            this.allowPartClassFromHeader = 
Boolean.toString(allowPartClassFromHeader);
+            return this;
+        }
+
         /**
          * When marshalling using JAXB or SOAP then the JAXB implementation 
will automatically assign namespace
          * prefixes, such as ns2, ns3, ns4 etc. To control this mapping, Camel 
allows you to refer to a map which
diff --git 
a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/dataformat/JaxbDataFormatReifier.java
 
b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/dataformat/JaxbDataFormatReifier.java
index 7bd50abbdf04..3eb6f4b27aee 100644
--- 
a/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/dataformat/JaxbDataFormatReifier.java
+++ 
b/core/camel-core-reifier/src/main/java/org/apache/camel/reifier/dataformat/JaxbDataFormatReifier.java
@@ -40,6 +40,7 @@ public class JaxbDataFormatReifier extends 
DataFormatReifier<JaxbDataFormat> {
         properties.put("contextPathIsClassName", 
definition.getContextPathIsClassName());
         properties.put("partClass", definition.getPartClass());
         properties.put("partNamespace", definition.getPartNamespace());
+        properties.put("allowPartClassFromHeader", 
definition.getAllowPartClassFromHeader());
         properties.put("encoding", definition.getEncoding());
         properties.put("namespacePrefix", 
asRef(definition.getNamespacePrefix()));
         properties.put("schema", definition.getSchema());
diff --git 
a/core/camel-java-io/src/generated/java/org/apache/camel/java/out/JavaDslModelWriter.java
 
b/core/camel-java-io/src/generated/java/org/apache/camel/java/out/JavaDslModelWriter.java
index 23eb4493412b..215ba568748e 100644
--- 
a/core/camel-java-io/src/generated/java/org/apache/camel/java/out/JavaDslModelWriter.java
+++ 
b/core/camel-java-io/src/generated/java/org/apache/camel/java/out/JavaDslModelWriter.java
@@ -3117,6 +3117,7 @@ public class JavaDslModelWriter extends 
JavaDslModelWriterSupport {
         doWriteAttribute(sb, "fragment", def.getFragment(), null);
         doWriteAttribute(sb, "partClass", def.getPartClass(), null);
         doWriteAttribute(sb, "partNamespace", def.getPartNamespace(), null);
+        doWriteAttribute(sb, "allowPartClassFromHeader", 
def.getAllowPartClassFromHeader(), null);
         doWriteAttribute(sb, "namespacePrefix", def.getNamespacePrefix(), 
null);
         doWriteAttribute(sb, "xmlStreamWriterWrapper", 
def.getXmlStreamWriterWrapper(), null);
         doWriteAttribute(sb, "schemaLocation", def.getSchemaLocation(), null);
diff --git 
a/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java 
b/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java
index a2e3fadd1499..3d2297dff7f6 100644
--- 
a/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java
+++ 
b/core/camel-xml-io/src/generated/java/org/apache/camel/xml/in/ModelParser.java
@@ -1859,6 +1859,7 @@ public class ModelParser extends BaseParser {
     protected JaxbDataFormat doParseJaxbDataFormat() throws IOException, 
XmlPullParserException {
         return doParse(new JaxbDataFormat(), (def, key, val) -> switch (key) {
                 case "accessExternalSchemaProtocols": 
def.setAccessExternalSchemaProtocols(val); yield true;
+                case "allowPartClassFromHeader": 
def.setAllowPartClassFromHeader(val); yield true;
                 case "contentTypeHeader": def.setContentTypeHeader(val); yield 
true;
                 case "contextPath": def.setContextPath(val); yield true;
                 case "contextPathIsClassName": 
def.setContextPathIsClassName(val); yield true;
diff --git 
a/core/camel-xml-io/src/generated/java/org/apache/camel/xml/out/ModelWriter.java
 
b/core/camel-xml-io/src/generated/java/org/apache/camel/xml/out/ModelWriter.java
index ce3381086f0e..bc631634bef8 100644
--- 
a/core/camel-xml-io/src/generated/java/org/apache/camel/xml/out/ModelWriter.java
+++ 
b/core/camel-xml-io/src/generated/java/org/apache/camel/xml/out/ModelWriter.java
@@ -2482,6 +2482,7 @@ public class ModelWriter extends BaseWriter {
         doWriteAttribute("fragment", def.getFragment(), null);
         doWriteAttribute("partClass", def.getPartClass(), null);
         doWriteAttribute("partNamespace", def.getPartNamespace(), null);
+        doWriteAttribute("allowPartClassFromHeader", 
def.getAllowPartClassFromHeader(), null);
         doWriteAttribute("namespacePrefix", def.getNamespacePrefix(), null);
         doWriteAttribute("xmlStreamWriterWrapper", 
def.getXmlStreamWriterWrapper(), null);
         doWriteAttribute("schemaLocation", def.getSchemaLocation(), null);
diff --git 
a/core/camel-yaml-io/src/generated/java/org/apache/camel/yaml/out/YamlModelWriter.java
 
b/core/camel-yaml-io/src/generated/java/org/apache/camel/yaml/out/YamlModelWriter.java
index 8d05ca993175..4b22e19ffcf6 100644
--- 
a/core/camel-yaml-io/src/generated/java/org/apache/camel/yaml/out/YamlModelWriter.java
+++ 
b/core/camel-yaml-io/src/generated/java/org/apache/camel/yaml/out/YamlModelWriter.java
@@ -2480,6 +2480,7 @@ public class YamlModelWriter extends 
YamlModelWriterSupport {
         doWriteAttribute(jo, "fragment", def.getFragment(), null);
         doWriteAttribute(jo, "partClass", def.getPartClass(), null);
         doWriteAttribute(jo, "partNamespace", def.getPartNamespace(), null);
+        doWriteAttribute(jo, "allowPartClassFromHeader", 
def.getAllowPartClassFromHeader(), null);
         doWriteAttribute(jo, "namespacePrefix", def.getNamespacePrefix(), 
null);
         doWriteAttribute(jo, "xmlStreamWriterWrapper", 
def.getXmlStreamWriterWrapper(), null);
         doWriteAttribute(jo, "schemaLocation", def.getSchemaLocation(), null);
diff --git 
a/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializers.java
 
b/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializers.java
index 786f368c0995..27e105c36b1c 100644
--- 
a/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializers.java
+++ 
b/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializers.java
@@ -7769,6 +7769,7 @@ public final class ModelDeserializers extends 
YamlDeserializerSupport {
             deprecated = false,
             properties = {
                     @YamlProperty(name = "accessExternalSchemaProtocols", type 
= "string", description = "Only in use if schema validation has been enabled. 
Restrict access to the protocols specified for external reference set by the 
schemaLocation attribute, Import and Include element.", displayName = "Access 
External Schema Protocols"),
+                    @YamlProperty(name = "allowPartClassFromHeader", type = 
"boolean", defaultValue = "false", description = "Whether the 
CamelJaxbPartClass and CamelJaxbPartNamespace headers are used, when set, 
instead of the partClass and partNamespace options when marshalling and 
unmarshalling. Enable it only when the route sets these headers itself, not on 
routes that receive them from external systems.", displayName = "Allow Part 
Class From Header"),
                     @YamlProperty(name = "contentTypeHeader", type = 
"boolean", defaultValue = "true", description = "Whether the data format should 
set the Content-Type header with the type from the data format. For example 
application/xml for data formats marshalling to XML, or application/json for 
data formats marshalling to JSON", displayName = "Content Type Header"),
                     @YamlProperty(name = "contextPath", type = "string", 
required = true, description = "Package name where your JAXB classes are 
located.", displayName = "Context Path"),
                     @YamlProperty(name = "contextPathIsClassName", type = 
"boolean", defaultValue = "false", description = "This can be set to true to 
mark that the contextPath is referring to a classname and not a package name.", 
displayName = "Context Path Is Class Name"),
@@ -7811,6 +7812,11 @@ public final class ModelDeserializers extends 
YamlDeserializerSupport {
                     target.setAccessExternalSchemaProtocols(val);
                     break;
                 }
+                case "allowPartClassFromHeader": {
+                    String val = asText(node);
+                    target.setAllowPartClassFromHeader(val);
+                    break;
+                }
                 case "contentTypeHeader": {
                     String val = asText(node);
                     target.setContentTypeHeader(val);
diff --git 
a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl-canonical.json
 
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl-canonical.json
index 85101e8dd74d..646fd1048bd3 100644
--- 
a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl-canonical.json
+++ 
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl-canonical.json
@@ -7593,6 +7593,12 @@
             "title" : "Access External Schema Protocols",
             "description" : "Only in use if schema validation has been 
enabled. Restrict access to the protocols specified for external reference set 
by the schemaLocation attribute, Import and Include element."
           },
+          "allowPartClassFromHeader" : {
+            "type" : "boolean",
+            "title" : "Allow Part Class From Header",
+            "description" : "Whether the CamelJaxbPartClass and 
CamelJaxbPartNamespace headers are used, when set, instead of the partClass and 
partNamespace options when marshalling and unmarshalling. Enable it only when 
the route sets these headers itself, not on routes that receive them from 
external systems.",
+            "default" : false
+          },
           "contentTypeHeader" : {
             "type" : "boolean",
             "title" : "Content Type Header",
diff --git 
a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl-model.json
 
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl-model.json
index 0e2a74f1d16c..2b267e110bc1 100644
--- 
a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl-model.json
+++ 
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl-model.json
@@ -12076,6 +12076,17 @@
         "index" : 13,
         "group" : "advanced",
         "label" : "advanced"
+      }, {
+        "name" : "allowPartClassFromHeader",
+        "type" : "boolean",
+        "description" : "Whether the CamelJaxbPartClass and 
CamelJaxbPartNamespace headers are used, when set, instead of the partClass and 
partNamespace options when marshalling and unmarshalling. Enable it only when 
the route sets these headers itself, not on routes that receive them from 
external systems.",
+        "title" : "Allow Part Class From Header",
+        "default" : "false",
+        "displayName" : "Allow Part Class From Header",
+        "kind" : "attribute",
+        "index" : 14,
+        "group" : "advanced",
+        "label" : "advanced"
       }, {
         "name" : "namespacePrefix",
         "type" : "string",
@@ -12083,7 +12094,7 @@
         "title" : "Namespace Prefix",
         "displayName" : "Namespace Prefix",
         "kind" : "attribute",
-        "index" : 14,
+        "index" : 15,
         "group" : "advanced",
         "label" : "advanced"
       }, {
@@ -12093,7 +12104,7 @@
         "title" : "Xml Stream Writer Wrapper",
         "displayName" : "Xml Stream Writer Wrapper",
         "kind" : "attribute",
-        "index" : 15,
+        "index" : 16,
         "group" : "advanced",
         "label" : "advanced"
       }, {
@@ -12103,7 +12114,7 @@
         "title" : "Schema Location",
         "displayName" : "Schema Location",
         "kind" : "attribute",
-        "index" : 16,
+        "index" : 17,
         "group" : "common"
       }, {
         "name" : "noNamespaceSchemaLocation",
@@ -12112,7 +12123,7 @@
         "title" : "No Namespace Schema Location",
         "displayName" : "No Namespace Schema Location",
         "kind" : "attribute",
-        "index" : 17,
+        "index" : 18,
         "group" : "advanced",
         "label" : "advanced"
       }, {
@@ -12122,7 +12133,7 @@
         "title" : "Jaxb Provider Properties",
         "displayName" : "Jaxb Provider Properties",
         "kind" : "attribute",
-        "index" : 18,
+        "index" : 19,
         "group" : "advanced",
         "label" : "advanced"
       }, {
@@ -12133,7 +12144,7 @@
         "default" : "true",
         "displayName" : "Content Type Header",
         "kind" : "attribute",
-        "index" : 19,
+        "index" : 20,
         "group" : "common"
       }, {
         "name" : "accessExternalSchemaProtocols",
@@ -12142,7 +12153,7 @@
         "title" : "Access External Schema Protocols",
         "displayName" : "Access External Schema Protocols",
         "kind" : "attribute",
-        "index" : 20,
+        "index" : 21,
         "group" : "security",
         "label" : "security"
       } ]
diff --git 
a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl.json
 
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl.json
index 08cf52c5a05a..dad48168a7bd 100644
--- 
a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl.json
+++ 
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl.json
@@ -11003,6 +11003,12 @@
             "title" : "Access External Schema Protocols",
             "description" : "Only in use if schema validation has been 
enabled. Restrict access to the protocols specified for external reference set 
by the schemaLocation attribute, Import and Include element."
           },
+          "allowPartClassFromHeader" : {
+            "type" : "boolean",
+            "title" : "Allow Part Class From Header",
+            "description" : "Whether the CamelJaxbPartClass and 
CamelJaxbPartNamespace headers are used, when set, instead of the partClass and 
partNamespace options when marshalling and unmarshalling. Enable it only when 
the route sets these headers itself, not on routes that receive them from 
external systems.",
+            "default" : false
+          },
           "contentTypeHeader" : {
             "type" : "boolean",
             "title" : "Content Type Header",

Reply via email to