Reputation: 3
Context When I don't import this library (org.apache.camel - camel-jaxb), the code performs the conversions normally from json to pojo, pojo to xml and xml to pojo, but i want to use javax annotations for namespace and xsd
sample repository with included json file repository link github
image: library camel json to pojo - pojo to xml - xml to pojo
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jaxb</artifactId>
<version>${camel.version}</version>
</dependency>
from("file:file/json").to("direct:my-activemq-xml-queue");
from("direct:my-activemq-xml-queue").unmarshal().json(JsonLibrary.Jackson, CurrencyExchange.class)
.to("bean-validator://x?group=javax.validation.groups.Default")
.log("${body} ::::::::::::::::pojo:::::::::::::::").marshal().jacksonxml(CurrencyExchange.class)
.log("${body} :::::::::::::::::::::xml:::::::::::::::::").to("direct:my-activemq-xml-json-queue");
// converto xml to pojo
from("direct:my-activemq-xml-json-queue").unmarshal().jacksonxml(CurrencyExchange.class)
.to("log:received-message-from-active-mq");
normal conversions
when I move the file it works normal but it doesn't bring me name space and xsd but it works normal
2021-03-31 11:58:45.031 INFO 33552 --- [ile://file/json] route2 : CurrencyExchange [id=1002, [email protected], to=DRAFT, conversionMultiple=10, bool=true, table=table [[email protected], value=cc]] ::::::pojo::::
2021-03-31 11:58:45.093 INFO 33552 --- [ile://file/json] route2 : <CurrencyExchange><id>1002</id><from>[email protected]</from><to>DRAFT</to><conversionMultiple>10</conversionMultiple><bool>true</bool><table><key>[email protected]</key><value>cc</value></table></CurrencyExchange> :::xml:
2021-03-31 11:58:45.160 INFO 33552 --- [ile://file/json] received-message-from-active-mq : Exchange[ExchangePattern: InOnly, BodyType: com.cam.camelmicroservicesb.routes.dto.response.CurrencyExchange, Body: CurrencyExchange [id=1002, [email protected], to=DRAFT, conversionMultiple=10, bool=true, table=table [[email protected], value=cc]]]
Error But when I import this library, all the conversions are generated in xml
2021-03-31 11:30:51.012[0;39m [32m INFO[0;39m [35m34556[0;39m [2m---[0;39m [2m[ile://file/json][0;39m [36mroute2 [0;39m [2m:[0;39m <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns2:currencyExchange xmlns:NS2="http://www.test.com/testml" xmlns:ns2="http://www.test.com/testxml">
<ns2:id>1002</ns2:id>
<ns2:From>[email protected]</ns2:From>
<ns2:to>DRAFT</ns2:to>
<ns2:ConversionMultiple>10</ns2:ConversionMultiple>
<ns2:bool>true</ns2:bool>
<ns2:table>
<keyRequest>[email protected]</keyRequest>
<valuePcRequest>cc</valuePcRequest>
</ns2:table>
</ns2:currencyExchange>
::::::::::::::::pojo:::::::::::::::
[2m2021-03-31 11:30:51.061[0;39m [32m INFO[0;39m [35m34556[0;39m [2m---[0;39m [2m[ile://file/json][0;39m [36mroute2 [0;39m [2m:[0;39m <CurrencyExchange><id>1002</id><from>[email protected]</from><to>DRAFT</to><conversionMultiple>10</conversionMultiple><bool>true</bool><table><key>[email protected]</key><value>cc</value></table></CurrencyExchange> :::::::::::::::::::::xml:::::::::::::::::
[2m2021-03-31 11:30:51.114[0;39m [32m INFO[0;39m [35m34556[0;39m [2m---[0;39m [2m[ile://file/json][0;39m [36mreceived-message-from-active-mq [0;39m [2m:[0;39m Exchange[ExchangePattern: InOnly, BodyType: com.cam.camelmicroservicesb.routes.dto.response.CurrencyExchange, Body: <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns2:currencyExchange xmlns:NS2="http://www.test.com/testml" xmlns:ns2="http://www.test.com/testxml">
<ns2:id>1002</ns2:id>
<ns2:From>[email protected]</ns2:From>
<ns2:to>DRAFT</ns2:to>
<ns2:ConversionMultiple>10</ns2:ConversionMultiple>
<ns2:bool>true</ns2:bool>
<ns2:table>
<keyRequest>[email protected]</keyRequest>
<valuePcRequest>cc</valuePcRequest>
</ns2:table>
</ns2:currencyExchange>
]
Upvotes: 0
Views: 201