Apache Camel route marshall Java Object to XML

问题描述 投票:0回答:1

我有带有XML批注的Java对象

@XmlRootElement(name = "ROOT")
public class Root {

    @XmlAttribute(name = "ATTR")
    private long site;

    @XmlElement(name = "LIST")
    List<MyObject> transaction;
}

并且我有路由到文件夹

from("firstPoint")
                .process(new RootToXMLConvertor())
                .to(FTP_FOLDER)
                .end();

我想将我的Root对象(在exchange.getIn().getBody()中拥有它)编组为XML文件并发送到FTP_FOLDER。

apache-camel marshalling camel-ftp
1个回答
0
投票

您可以使用Camel的JacksonXML数据格式

JacksonXMLDataFormat formatPojo = new JacksonXMLDataFormat(Root.class);
from("firstPoint")
                .marshall(formatPojo)
                .to("file..")
                .to(FTP_FOLDER);

为此,您将需要camel-jacksonxml,camel-ftp和camel-file组件。

© www.soinside.com 2019 - 2024. All rights reserved.