This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch jx in repository https://gitbox.apache.org/repos/asf/camel.git
commit ffa34be14d4cec864fe77c3356d0553cd51055c6 Author: Claus Ibsen <[email protected]> AuthorDate: Tue Oct 14 15:10:31 2025 +0200 CAMEL-22542: rest-dsl - Add support for using camel-jacksonxml for XML pojo binding (instead of jaxb) --- .../rest-binding-jacksonxml-dataformat-factory | 2 + ...XMLRestBindingJacksonXmlDataFormatFactory.java} | 29 ++++---- .../jaxb/JaxbRestBindingJaxbDataFormatFactory.java | 1 + components/camel-jetty/pom.xml | 5 ++ .../rest/RestJettyBindingModeJacksonXmlTest.java | 78 ++++++++++++++++++++++ .../component/jetty/rest/UserJacksonXmlPojo.java | 45 +++++++++++++ .../RestBindingJacksonXmlDataFormatFactory.java | 40 +++++++++++ .../camel/impl/engine/AbstractCamelContext.java | 5 ++ .../camel/impl/engine/SimpleCamelContext.java | 17 +++++ .../org/apache/camel/support/PluginHelper.java | 16 +++++ .../processor/RestBindingAdviceFactory.java | 35 ++++++---- docs/user-manual/modules/ROOT/pages/rest-dsl.adoc | 12 +++- 12 files changed, 253 insertions(+), 32 deletions(-) diff --git a/components/camel-jacksonxml/src/generated/resources/META-INF/services/org/apache/camel/rest-binding-jacksonxml-dataformat-factory b/components/camel-jacksonxml/src/generated/resources/META-INF/services/org/apache/camel/rest-binding-jacksonxml-dataformat-factory new file mode 100644 index 000000000000..0f0e36e8207e --- /dev/null +++ b/components/camel-jacksonxml/src/generated/resources/META-INF/services/org/apache/camel/rest-binding-jacksonxml-dataformat-factory @@ -0,0 +1,2 @@ +# Generated by camel build tools - do NOT edit this file! +class=org.apache.camel.component.jacksonxml.JacksonXMLRestBindingJacksonXmlDataFormatFactory diff --git a/components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/JaxbRestBindingJaxbDataFormatFactory.java b/components/camel-jacksonxml/src/main/java/org/apache/camel/component/jacksonxml/JacksonXMLRestBindingJacksonXmlDataFormatFactory.java similarity index 85% copy from components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/JaxbRestBindingJaxbDataFormatFactory.java copy to components/camel-jacksonxml/src/main/java/org/apache/camel/component/jacksonxml/JacksonXMLRestBindingJacksonXmlDataFormatFactory.java index 970bc8a36405..a79c14247b82 100644 --- a/components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/JaxbRestBindingJaxbDataFormatFactory.java +++ b/components/camel-jacksonxml/src/main/java/org/apache/camel/component/jacksonxml/JacksonXMLRestBindingJacksonXmlDataFormatFactory.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.converter.jaxb; +package org.apache.camel.component.jacksonxml; import java.util.HashMap; import java.util.Map; @@ -22,28 +22,29 @@ import java.util.Map; import org.apache.camel.CamelContext; import org.apache.camel.spi.DataFormat; import org.apache.camel.spi.PropertyConfigurer; -import org.apache.camel.spi.RestBindingJaxbDataFormatFactory; +import org.apache.camel.spi.RestBindingJacksonXmlDataFormatFactory; import org.apache.camel.spi.RestConfiguration; import org.apache.camel.spi.annotations.JdkService; import org.apache.camel.support.PluginHelper; import org.apache.camel.support.PropertyBindingSupport; /** - * JAXB based {@link RestBindingJaxbDataFormatFactory}. + * Jackson based {@link RestBindingJacksonXmlDataFormatFactory}. */ -@JdkService(RestBindingJaxbDataFormatFactory.FACTORY) -public class JaxbRestBindingJaxbDataFormatFactory implements RestBindingJaxbDataFormatFactory { +@JdkService(RestBindingJacksonXmlDataFormatFactory.FACTORY) +public class JacksonXMLRestBindingJacksonXmlDataFormatFactory implements RestBindingJacksonXmlDataFormatFactory { + @Override - public void setupJaxb( + public void setupJacksonXml( CamelContext camelContext, RestConfiguration config, String type, Class<?> typeClass, String outType, Class<?> outTypeClass, - DataFormat jaxb, DataFormat outJaxb) + DataFormat xml, DataFormat outXml) throws Exception { // lookup configurer PropertyConfigurer configurer = PluginHelper.getConfigurerResolver(camelContext) - .resolvePropertyConfigurer("jaxb-dataformat-configurer", camelContext); + .resolvePropertyConfigurer("jacksonXml-dataformat-configurer", camelContext); if (configurer == null) { - throw new IllegalStateException("Cannot find configurer for dataformat: jaxb"); + throw new IllegalStateException("Cannot find configurer for dataformat: jacksonXml"); } // @@ -53,12 +54,11 @@ public class JaxbRestBindingJaxbDataFormatFactory implements RestBindingJaxbData PropertyBindingSupport.Builder builder = PropertyBindingSupport.build() .withCamelContext(camelContext) .withConfigurer(configurer) - .withTarget(jaxb); + .withTarget(xml); final String typeName = getTypeName(type, typeClass); if (typeName != null) { - builder.withProperty("contextPath", typeName); - builder.withProperty("contextPathIsClassName", "true"); + builder.withProperty("unmarshalTypeName", typeName); } setAdditionalConfiguration(config, "xml.in.", builder); @@ -71,13 +71,12 @@ public class JaxbRestBindingJaxbDataFormatFactory implements RestBindingJaxbData PropertyBindingSupport.Builder outBuilder = PropertyBindingSupport.build() .withCamelContext(camelContext) .withConfigurer(configurer) - .withTarget(outJaxb); + .withTarget(outXml); final String outTypeName = getOutTypeName(outType, outTypeClass, typeName); if (outTypeName != null) { - outBuilder.withProperty("contextPath", outTypeName); - outBuilder.withProperty("contextPathIsClassName", "true"); + outBuilder.withProperty("unmarshalTypeName", outTypeName); } setAdditionalConfiguration(config, "xml.out.", outBuilder); diff --git a/components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/JaxbRestBindingJaxbDataFormatFactory.java b/components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/JaxbRestBindingJaxbDataFormatFactory.java index 970bc8a36405..cedbd5fe90d8 100644 --- a/components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/JaxbRestBindingJaxbDataFormatFactory.java +++ b/components/camel-jaxb/src/main/java/org/apache/camel/converter/jaxb/JaxbRestBindingJaxbDataFormatFactory.java @@ -33,6 +33,7 @@ import org.apache.camel.support.PropertyBindingSupport; */ @JdkService(RestBindingJaxbDataFormatFactory.FACTORY) public class JaxbRestBindingJaxbDataFormatFactory implements RestBindingJaxbDataFormatFactory { + @Override public void setupJaxb( CamelContext camelContext, RestConfiguration config, diff --git a/components/camel-jetty/pom.xml b/components/camel-jetty/pom.xml index f60cbea566e1..788c46ba5279 100644 --- a/components/camel-jetty/pom.xml +++ b/components/camel-jetty/pom.xml @@ -142,6 +142,11 @@ <artifactId>camel-jackson</artifactId> <scope>test</scope> </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-jacksonxml</artifactId> + <scope>test</scope> + </dependency> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-jaxb</artifactId> diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/rest/RestJettyBindingModeJacksonXmlTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/rest/RestJettyBindingModeJacksonXmlTest.java new file mode 100644 index 000000000000..df2bbc1813e4 --- /dev/null +++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/rest/RestJettyBindingModeJacksonXmlTest.java @@ -0,0 +1,78 @@ +/* + * 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.component.jetty.rest; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.jetty.BaseJettyTest; +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.model.rest.RestBindingMode; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.fail; + +public class RestJettyBindingModeJacksonXmlTest extends BaseJettyTest { + + @Test + public void testBindingMode() throws Exception { + MockEndpoint mock = getMockEndpoint("mock:input"); + mock.expectedMessageCount(1); + mock.message(0).body().isInstanceOf(UserJacksonXmlPojo.class); + + String body = "<user name=\"Donald Duck\" id=\"123\"></user>"; + template.sendBody("http://localhost:" + getPort() + "/users/new", body); + + MockEndpoint.assertIsSatisfied(context); + + UserJacksonXmlPojo user = mock.getReceivedExchanges().get(0).getIn().getBody(UserJacksonXmlPojo.class); + assertNotNull(user); + assertEquals(123, user.getIdentifier()); + assertEquals("Donald Duck", user.getUserName()); + } + + @Test + public void testBindingModeWrong() throws Exception { + MockEndpoint mock = getMockEndpoint("mock:input"); + mock.expectedMessageCount(0); + + // we bind to xml, but send in json, which is not possible + String body = "{\"id\": 123, \"name\": \"Donald Duck\"}"; + try { + template.sendBody("http://localhost:" + getPort() + "/users/new", body); + fail("Should have thrown exception"); + } catch (Exception e) { + // expected + } + + MockEndpoint.assertIsSatisfied(context); + } + + @Override + protected RouteBuilder createRouteBuilder() { + return new RouteBuilder() { + @Override + public void configure() { + restConfiguration().component("jetty").host("localhost").port(getPort()) + .bindingMode(RestBindingMode.xml).xmlDataFormat("jacksonXml"); + + // use the rest DSL to define the rest services + rest("/users/").post("new").type(UserJacksonXmlPojo.class).to("mock:input"); + } + }; + } +} diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/rest/UserJacksonXmlPojo.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/rest/UserJacksonXmlPojo.java new file mode 100644 index 000000000000..84198e318160 --- /dev/null +++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/rest/UserJacksonXmlPojo.java @@ -0,0 +1,45 @@ +/* + * 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.component.jetty.rest; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; + +@JsonRootName(value = "user") +public class UserJacksonXmlPojo { + + @JsonProperty("id") + private int identifier; + @JsonProperty("name") + private String userName; + + public int getIdentifier() { + return identifier; + } + + public void setIdentifier(int identifier) { + this.identifier = identifier; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } +} diff --git a/core/camel-api/src/main/java/org/apache/camel/spi/RestBindingJacksonXmlDataFormatFactory.java b/core/camel-api/src/main/java/org/apache/camel/spi/RestBindingJacksonXmlDataFormatFactory.java new file mode 100644 index 000000000000..ac032e1d41b7 --- /dev/null +++ b/core/camel-api/src/main/java/org/apache/camel/spi/RestBindingJacksonXmlDataFormatFactory.java @@ -0,0 +1,40 @@ +/* + * 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.spi; + +import org.apache.camel.CamelContext; + +/** + * SPI for setting up XML data format (jacksonXml) for rest-dsl. + */ +public interface RestBindingJacksonXmlDataFormatFactory { + + /** + * Service factory key. + */ + String FACTORY = "rest-binding-jacksonxml-dataformat-factory"; + + /** + * Setup XML data format + */ + void setupJacksonXml( + CamelContext camelContext, RestConfiguration config, + String type, Class<?> typeClass, String outType, Class<?> outTypeClass, + DataFormat jacksonXml, DataFormat outJacksonXml) + throws Exception; + +} diff --git a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java index 5477a2773ea1..681e00ad5a08 100644 --- a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java +++ b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/AbstractCamelContext.java @@ -152,6 +152,7 @@ import org.apache.camel.spi.PropertiesComponent; import org.apache.camel.spi.ReactiveExecutor; import org.apache.camel.spi.Registry; import org.apache.camel.spi.ResourceLoader; +import org.apache.camel.spi.RestBindingJacksonXmlDataFormatFactory; import org.apache.camel.spi.RestBindingJaxbDataFormatFactory; import org.apache.camel.spi.RestConfiguration; import org.apache.camel.spi.RestRegistry; @@ -382,6 +383,8 @@ public abstract class AbstractCamelContext extends BaseService camelContextExtension.lazyAddContextPlugin(RuntimeCamelCatalog.class, this::createRuntimeCamelCatalog); camelContextExtension.lazyAddContextPlugin(RestBindingJaxbDataFormatFactory.class, this::createRestBindingJaxbDataFormatFactory); + camelContextExtension.lazyAddContextPlugin(RestBindingJacksonXmlDataFormatFactory.class, + this::createRestBindingJacksonXmlDataFormatFactory); camelContextExtension.lazyAddContextPlugin(BeanProxyFactory.class, this::createBeanProxyFactory); camelContextExtension.lazyAddContextPlugin(UnitOfWorkFactory.class, this::createUnitOfWorkFactory); camelContextExtension.lazyAddContextPlugin(BeanIntrospection.class, this::createBeanIntrospection); @@ -4457,6 +4460,8 @@ public abstract class AbstractCamelContext extends BaseService protected abstract RestBindingJaxbDataFormatFactory createRestBindingJaxbDataFormatFactory(); + protected abstract RestBindingJacksonXmlDataFormatFactory createRestBindingJacksonXmlDataFormatFactory(); + protected abstract RuntimeCamelCatalog createRuntimeCamelCatalog(); protected abstract DumpRoutesStrategy createDumpRoutesStrategy(); diff --git a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/SimpleCamelContext.java b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/SimpleCamelContext.java index f25f6f7775b5..0a4a0a53fbe1 100644 --- a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/SimpleCamelContext.java +++ b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/SimpleCamelContext.java @@ -83,6 +83,7 @@ import org.apache.camel.spi.PropertiesComponent; import org.apache.camel.spi.ReactiveExecutor; import org.apache.camel.spi.Registry; import org.apache.camel.spi.ResourceLoader; +import org.apache.camel.spi.RestBindingJacksonXmlDataFormatFactory; import org.apache.camel.spi.RestBindingJaxbDataFormatFactory; import org.apache.camel.spi.RestRegistryFactory; import org.apache.camel.spi.RouteController; @@ -638,6 +639,22 @@ public class SimpleCamelContext extends AbstractCamelContext { } } + @Override + protected RestBindingJacksonXmlDataFormatFactory createRestBindingJacksonXmlDataFormatFactory() { + Optional<RestBindingJacksonXmlDataFormatFactory> result = ResolverHelper.resolveService( + getCamelContextReference(), + getCamelContextExtension().getBootstrapFactoryFinder(), + RestBindingJacksonXmlDataFormatFactory.FACTORY, + RestBindingJacksonXmlDataFormatFactory.class); + + if (result.isPresent()) { + return result.get(); + } else { + throw new IllegalArgumentException( + "Cannot find RestBindingJacksonXmlDataFormatFactory on classpath. Add camel-jacksonxml to classpath."); + } + } + @Override protected Tracer createTracer() { Tracer tracer = null; diff --git a/core/camel-support/src/main/java/org/apache/camel/support/PluginHelper.java b/core/camel-support/src/main/java/org/apache/camel/support/PluginHelper.java index aae3c7c8536b..3de356481544 100644 --- a/core/camel-support/src/main/java/org/apache/camel/support/PluginHelper.java +++ b/core/camel-support/src/main/java/org/apache/camel/support/PluginHelper.java @@ -50,6 +50,7 @@ import org.apache.camel.spi.PeriodTaskResolver; import org.apache.camel.spi.PeriodTaskScheduler; import org.apache.camel.spi.ProcessorFactory; import org.apache.camel.spi.ResourceLoader; +import org.apache.camel.spi.RestBindingJacksonXmlDataFormatFactory; import org.apache.camel.spi.RestBindingJaxbDataFormatFactory; import org.apache.camel.spi.RouteFactory; import org.apache.camel.spi.RoutesLoader; @@ -451,6 +452,21 @@ public final class PluginHelper { return extendedCamelContext.getContextPlugin(RestBindingJaxbDataFormatFactory.class); } + /** + * Gets the {@link RestBindingJacksonXmlDataFormatFactory} to be used. + */ + public static RestBindingJacksonXmlDataFormatFactory getRestBindingJacksonXmlDataFormatFactory(CamelContext camelContext) { + return getRestBindingJacksonXmlDataFormatFactory(camelContext.getCamelContextExtension()); + } + + /** + * Gets the {@link RestBindingJacksonXmlDataFormatFactory} to be used. + */ + public static RestBindingJacksonXmlDataFormatFactory getRestBindingJacksonXmlDataFormatFactory( + ExtendedCamelContext extendedCamelContext) { + return extendedCamelContext.getContextPlugin(RestBindingJacksonXmlDataFormatFactory.class); + } + /** * Gets the {@link BeanProxyFactory} to use. */ diff --git a/core/camel-support/src/main/java/org/apache/camel/support/processor/RestBindingAdviceFactory.java b/core/camel-support/src/main/java/org/apache/camel/support/processor/RestBindingAdviceFactory.java index b381c6fb7f99..70977c46108c 100644 --- a/core/camel-support/src/main/java/org/apache/camel/support/processor/RestBindingAdviceFactory.java +++ b/core/camel-support/src/main/java/org/apache/camel/support/processor/RestBindingAdviceFactory.java @@ -86,8 +86,8 @@ public class RestBindingAdviceFactory { } // setup xml data format - DataFormat jaxb = null; - DataFormat outJaxb = null; + DataFormat xml = null; + DataFormat outXml = null; if (mode.contains("xml") || "auto".equals(mode)) { String name = config.getXmlDataFormat(); if (name != null) { @@ -100,22 +100,29 @@ public class RestBindingAdviceFactory { } else { name = "jaxb"; } - // this will create a new instance as the name was not already - // pre-created - jaxb = camelContext.createDataFormat(name); - outJaxb = camelContext.createDataFormat(name); + // this will create a new instance as the name was not already pre-created + xml = camelContext.createDataFormat(name); + outXml = camelContext.createDataFormat(name); // is xml binding required? - if (mode.contains("xml") && jaxb == null) { + if (mode.contains("xml") && xml == null) { throw new IllegalArgumentException("XML DataFormat " + name + " not found."); } - if (jaxb != null) { - // to setup JAXB we need to use camel-jaxb - PluginHelper.getRestBindingJaxbDataFormatFactory(camelContext).setupJaxb(camelContext, config, - bc.getType(), bc.getTypeClass(), - bc.getOutType(), bc.getOutTypeClass(), - jaxb, outJaxb); + if (xml != null) { + if ("jacksonXml".equalsIgnoreCase(name)) { + // to setup jackson we need to use camel-jacksonxml + PluginHelper.getRestBindingJacksonXmlDataFormatFactory(camelContext).setupJacksonXml(camelContext, config, + bc.getType(), bc.getTypeClass(), + bc.getOutType(), bc.getOutTypeClass(), + xml, outXml); + } else { + // to setup JAXB we need to use camel-jaxb + PluginHelper.getRestBindingJaxbDataFormatFactory(camelContext).setupJaxb(camelContext, config, + bc.getType(), bc.getTypeClass(), + bc.getOutType(), bc.getOutTypeClass(), + xml, outXml); + } } } @@ -129,7 +136,7 @@ public class RestBindingAdviceFactory { } return new RestBindingAdvice( - camelContext, json, jaxb, outJson, outJaxb, + camelContext, json, xml, outJson, outXml, bc.getConsumes(), bc.getProduces(), mode, bc.isSkipBindingOnErrorCode(), bc.isClientRequestValidation(), bc.isClientResponseValidation(), bc.isEnableCORS(), bc.isEnableNoContentResponse(), bc.getCorsHeaders(), bc.getQueryDefaultValues(), bc.getQueryAllowedValues(), bc.isRequiredBody(), bc.getRequiredQueryParameters(), diff --git a/docs/user-manual/modules/ROOT/pages/rest-dsl.adoc b/docs/user-manual/modules/ROOT/pages/rest-dsl.adoc index 3f6efa3038d6..5c0a37fb833a 100644 --- a/docs/user-manual/modules/ROOT/pages/rest-dsl.adoc +++ b/docs/user-manual/modules/ROOT/pages/rest-dsl.adoc @@ -342,13 +342,14 @@ The binding modes are: |`auto` |Binding is enabled, and Camel is relaxed and supports JSON, XML or both if the necessary data formats are included in the classpath. Notice that if for example `camel-jaxb` is not on the classpath, then XML binding is -not enabled. +not enabled. Notice that for XML then `jaxb` is default, and you must be explicit to set `xmlDataFormat=jacksonXml` +if you want to use jackson XML instead. |`json` |Binding to/from JSON is enabled, and requires a JSON capable data format on the classpath. By default, Camel will use `jackson` as the data format. -|`xm` |Binding to/from XML is enabled, and requires `camel-jaxb` on the +|`xm` |Binding to/from XML is enabled, and requires `camel-jaxb` or `camel-jacksonxml` on the classpath. |`json_xml` |Binding to/from JSON and XML is enabled and requires both data formats to @@ -378,10 +379,15 @@ restConfiguration().dataFormatProperty("contentTypeHeader", "false"); ---- To use binding you must include the necessary data formats on the -classpath, such as `camel-jaxb` and/or `camel-jackson`. And then enable +classpath, such as `camel-jaxb` / `camel-jacksonxml` and/or `camel-jackson`. And then enable the binding mode. You can configure the binding mode globally on the rest configuration, and then override per rest service as well. +[NOTE] +==== +To use Jackson XML for XML binding, then you must configure `xmlDataformat=jacksonXml` and include `camel-jacksonxml` on the classpath. +==== + To enable binding, you configure this in Java DSL as shown below: [source,java]
