简体   繁体   English

使用Mule中的数据编织转换器将XML更改为POJO

[英]Changing XML to POJO using data weave transformer in mule

I am trying to convert a XML file to a POJO using data weave in mule, but it throws this exception -: 我正在尝试使用m子中的数据编织将XML文件转换为POJO,但是会引发此异常-:

Message : Exception while executing: time: payload.deliveryMessageDate.time ^ Type mismatch found :name, :binary required :name, :object Type : com.mulesoft.weave.mule.exception.WeaveExecutionException Code : MULE_ERROR--2 消息:执行时发生异常:时间:payload.deliveryMessageDate.time ^发现类型不匹配:名称,必需的二进制文件:名称,对象类型:com.mulesoft.weave.mule.exception.WeaveExecutionException代码:MULE_ERROR--2


Exception stack is: 1. Type mismatch found :name, :binary required :name, :object (com.mulesoft.weave.engine.ast.dynamic.DynamicDispatchException) com.mulesoft.weave.engine.ast.dynamic.DynamicDispatchNode:65 (null) 2. Exception while executing: time: payload.deliveryMessageDate.time ^ Type mismatch found :name, :binary required :name, :object (com.mulesoft.weave.mule.exception.WeaveExecutionException) com.mulesoft.weave.mule.WeaveMessageProcessor:124 (null) 异常堆栈为:1.发现类型不匹配::name,:binary必需的:name,:object(com.mulesoft.weave.engine.ast.dynamic.DynamicDispatchException)com.mulesoft.weave.engine.ast.dynamic.DynamicDispatchNode:65 (空)2.执行时发生异常:时间:payload.deliveryMessageDate.time ^发现类型不匹配:名称,所需的二进制文件:名称,对象(com.mulesoft.weave.mule.exception.WeaveExecutionException)com.mulesoft.weave。 mule.WeaveMessageProcessor:124(空)


Root Exception stack trace: com.mulesoft.weave.engine.ast.dynamic.DynamicDispatchException: Type mismatch found :name, :binary required :name, :object at com.mulesoft.weave.engine.ast.dynamic.DynamicDispatchNode.dispatchNode(DynamicDispatchNode.scala:65) at com.mulesoft.weave.engine.ast.dynamic.DynamicDispatchNode.valueType(DynamicDi... 根异常堆栈跟踪:com.mulesoft.weave.engine.ast.dynamic.DynamicDispatchException:发现类型不匹配:name,:binary required:name,:com.mulesoft.weave.engine.ast.dynamic.DynamicDispatchNode.dispatchNode( DynamicDispatchNode.scala:65),位于com.mulesoft.weave.engine.ast.dynamic.DynamicDispatchNode.valueType(DynamicDi ...

I haven't used any annotation on my POJO and the xml has some attributes inside the tags. 我没有在POJO上使用任何注释,并且xml在标记内具有一些属性。

You might have to format your date. 您可能需要格式化日期。 try to follow the below link if you still have problem please share your logic screen that will give clear idea. 如果您仍然有问题,请尝试点击以下链接,请共享您的逻辑屏幕,以明确思路。

Converting to a date format in Mule using DataWeave 使用DataWeave在Mule中转换为日期格式

Suppose Your Json is { "date": "2016-13-09" } 假设您的Json是{“ date”:“ 2016-13-09”}

Data weave for converting date is :- 用于转换日期的数据编织为:-

date : payload.date as :date {format: "yyyy-dd-MM"} as :string{format: "yyyyMMdd"} date:payload.date为:date {格式:“ yyyy-dd-MM”}为:string {format:“ yyyyMMdd”}

Firstly its match date and then convert to your specific formats. 首先是其匹配日期,然后转换为您的特定格式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM