0
  1. Created the Jaxb2Marshaller object.
  2. Need to convert a java POJO to XML (Marshalling).

Need help in integrating Jaxb2Marshaller in the Integration Route.

Code flow:-

@Bean
    public IntegrationFlow flow() throws JAXBException {
        return from(...).
                .enrichHeaders(...)
                .handle(...)
                .transform(processor()::generateXml)
                .channel(...)
                               .get();
    }

How can I add Jaxb2Marshaller in transform() step?

Amit Bhati
  • 5,569
  • 1
  • 24
  • 45

1 Answers1

0

There is an out-of-the-box transformer to use:

.transform(new MarshallingTransformer(jaxbMarshaller()))

https://docs.spring.io/spring-integration/docs/current/reference/html/xml.html#xml-marshalling-transformer

How to create a Jaxb2Marshaller you can consult Spring Framework docs:

https://docs.spring.io/spring/docs/current/spring-framework-reference/data-access.html#oxm-jaxb2

Artem Bilan
  • 113,505
  • 11
  • 91
  • 118
  • I don't see that transformer in spring-integration-core-5.0.5.RELEASE.jar, is it removed ? – Amit Bhati Aug 09 '18 at 23:11
  • It is a part if the `spring-integration-xml` module. So, you need to add that dependency in your project – Artem Bilan Aug 09 '18 at 23:35
  • Could someone help me with a Jaxb marshal issue? https://stackoverflow.com/questions/68031311/java-lang-illegalstateexception-marshaller-must-support-the-class-of-the-marsha – truekiller Jun 21 '21 at 09:07