当我将一个xml转换为另一个xml并在列表元素中进行映射列表时。我得到一个例外。
"不能将a:string强制转换为:object(com.mulesoft.weave.mule.exception.WeaveExecutionException)。消息有效负载的类型为:WeaveMessageProcessor $ WeaveOutputHandler"
输入xml:
<?xml version="1.0" encoding="UTF-8"?>
<ZCOM_IDD2565_AGREEMENT>
<transaction>
<id>www</id>
<timestamp>20160512 200939</timestamp>
<sender>ghh566</sender>
</transaction>
<identification>
<R3number>88898</R3number>
<enterpriseId />
<sourcesystemid>ffff</sourcesystemid>
<sourcesystemobjectid>999089</sourcesystemobjectid>
</identification>
<details>
<newTransaction>N</newTransaction>
<type>siiii</type>
<organizational>
<salesOrg>1223</salesOrg>
<currency>RUPEE</currency>
</organizational>
<description>
<internal>jhjb hjgjhg jkhjh</internal>
<external>jhhgjhb</external>
<project>owdoie</project>
</description>
<dates>
<validFrom>2016-04-05</validFrom>
<validTo>2017-04-30</validTo>
<fixedValue>0000-00-00</fixedValue>
</dates>
<creditTriggerEvent>S</creditTriggerEvent>
</details>
<rules>
<ZCOM_AGR_RULES>
<rule>
<ruleType>923</ruleType>
<agreementItem />
<ruleNumber />
<quantities>
<minimum />
<maximum />
</quantities>
<firstRecordA />
<application />
<conditionType>dddd</conditionType>
<salesOrg>1000</salesOrg>
<distributionChannel />
<division />
<endCustomerNumber />
<serialNumber />
<soldTo>
<ZCOM_AGR_SOLD>
<id>990888</id>
<addressNumber>2132435</addressNumber>
<name>dsfdg fdg</name>
<streetAddress>hu78hj k</streetAddress>
<postalCode>5654</postalCode>
<city>sfds</city>
<country>sdsa</country>
<phone>555-555-5555</phone>
<languageKey>E</languageKey>
<district />
<houseNumber>poio aaed</houseNumber>
<region>iii</region>
</ZCOM_AGR_SOLD>
<ZCOM_AGR_SOLD>
<id>777787</id>
<addressNumber>121223</addressNumber>
<name>dsfdg fdg</name>
<streetAddress>hu78hj k</streetAddress>
<postalCode>5654</postalCode>
<city>sfds</city>
<country>sdsa</country>
<phone>555-555-5555</phone>
<languageKey>E</languageKey>
<district />
<houseNumber>poio aaed</houseNumber>
<region>iii</region>
</ZCOM_AGR_SOLD>
</soldTo>
<shipTo>
<id />
<addressNumber />
<name />
<streetAddress />
<postalCode />
<city />
<country />
<phone />
<languageKey />
<district />
<houseNumber />
<region />
</shipTo>
<upc />
<catalogNumber />
<discountSchedule />
<priceGroupCode />
<priceFamily />
<requested-discount-netPrice />
<delete />
<customerRate />
<priceChange />
<dates>
<validFrom>2016-04-05</validFrom>
<validTo>2017-04-30</validTo>
<fixedValue>0000-00-00</fixedValue>
</dates>
<condition>
<type />
<calculationType />
<approved-discount-netPrice>0.00000</approved-discount-netPrice>
<unitOfMeasue />
<conditionitemindex />
<additionalvaluedays />
<fixedvaluedate />
<maxiumSalesOrdersPerConditionRecord />
<numberOfIncrementalScale />
<scaleNumberForPricing />
</condition>
</rule>
</ZCOM_AGR_RULES>
<ZCOM_AGR_RULES>
<rule>
<ruleType>920</ruleType>
<agreementItem />
<ruleNumber />
<quantities>
<minimum />
<maximum />
</quantities>
<firstRecordA />
<application />
<conditionType>rrrr</conditionType>
<salesOrg>1000</salesOrg>
<distributionChannel />
<division />
<endCustomerNumber />
<serialNumber />
<soldTo />
<shipTo>
<id />
<addressNumber />
<name />
<streetAddress />
<postalCode />
<city />
<country />
<phone />
<languageKey />
<district />
<houseNumber />
<region />
</shipTo>
<upc />
<catalogNumber />
<discountSchedule>B5</discountSchedule>
<priceGroupCode />
<priceFamily />
<requested-discount-netPrice>0.00</requested-discount-netPrice>
<delete />
<customerRate>0.44</customerRate>
<priceChange>X</priceChange>
<dates>
<validFrom>2016-04-05</validFrom>
<validTo>2017-04-30</validTo>
<fixedValue>0000-00-00</fixedValue>
</dates>
<condition>
<type>rrrr</type>
<calculationType>A</calculationType>
<approved-discount-netPrice>0.35000</approved-discount-netPrice>
<unitOfMeasue>%</unitOfMeasue>
<conditionitemindex />
<additionalvaluedays />
<fixedvaluedate />
<maxiumSalesOrdersPerConditionRecord />
<numberOfIncrementalScale />
<scaleNumberForPricing />
</condition>
</rule>
</ZCOM_AGR_RULES>
</rules>
</ZCOM_IDD2565_AGREEMENT>
数据编织脚本代码
%dw 1.0
%output application/xml
%type dtfield = :string { format: "yyyyMMdd" }
%namespace ns0 http://schemas.xmlsoap.org/soap/envelope/
%namespace ns1 FlexiWebService
---
{
ns0#Envelope: {
ns0#Header: {
ns1#AuthHeader: {
Username: "dssdfdf",
Password: "dfff"
}
},
ns0#Body: {
Z_IDDO735_IRM_AGRMNTS01: {
IDOC: {
'_-IRM_-AGMTK01': {
(TRANS: payload.ZCOM_IDD2565_AGREEMENT.details.newTransaction as :string) when payload.ZCOM_IDD2565_AGREEMENT.details.newTransaction?,
(BOART_AG: payload.ZCOM_IDD2565_AGREEMENT.details.type) when payload.ZCOM_IDD2565_AGREEMENT.details.type? ,
(AMTNUM: payload.ZCOM_IDD2565_AGREEMENT.identification.sourcesystemobjectid) when payload.ZCOM_IDD2565_AGREEMENT.identification.sourcesystemobjectid?,
(AGMTNUM_EXT: payload.ZCOM_IDD2565_AGREEMENT.details.description.external as :string) when payload.ZCOM_IDD2565_AGREEMENT.details.description.external?,
(AGMTTXT: payload.ZCOM_IDD2565_AGREEMENT.details.description.internal) when payload.ZCOM_IDD2565_AGREEMENT.details.description.internal?,
(VALID_FROM: payload.ZCOM_IDD2565_AGREEMENT.details.dates.validFrom as :dtfield replace "-" with "") when payload.ZCOM_IDD2565_AGREEMENT.details.dates.validFrom?,
(VALID_TO: payload.ZCOM_IDD2565_AGREEMENT.details.dates.validTo as :dtfield replace "-" with "") when payload.ZCOM_IDD2565_AGREEMENT.details.dates.validTo?,
'_-IRM_-AGMTK02': {
ZIDDO735_AGMTK02: {
(FV_DATE: payload.ZCOM_IDD2565_AGREEMENT.details.dates.fixedValue as :dtfield replace "-" with "") when payload.ZCOM_IDD2565_AGREEMENT.details.dates.fixedValue?,
(TDOBNAME: payload.ZCOM_IDD2565_AGREEMENT.details.creditTriggerEvent) when payload.ZCOM_IDD2565_AGREEMENT.details.creditTriggerEvent?
}
}
},
E1EDK14: {
(ORGID: payload.ZCOM_IDD2565_AGREEMENT.details.organizational.salesOrg) when payload.ZCOM_IDD2565_AGREEMENT.details.organizational.salesOrg?,
ZIDDO735_E1EDK14: {
(CURR: payload.ZCOM_IDD2565_AGREEMENT.details.organizational.currency) when payload.ZCOM_IDD2565_AGREEMENT.details.organizational.currency?
}
},
((payload.ZCOM_IDD2565_AGREEMENT.rules.*ZCOM_AGR_RULES default []) map {
E1KOMG:{
KVEWE: $.rule.firstRecordA,
KOTABNR: $.rule.condition.type,
KAPPL: $.rule.application,
VKORG: $.rule.salesOrg,
VTWEG: $.rule.distributionChannel,
EAN11: $.rule.upc,
KONDM: $.rule.discountSchedule,
EVRTP: $.rule.agreementItem,
HIENR: $.rule.endCustomerNumber,
POSNR: $.rule.ruleNumber,
ANZSN: $.rule.requested-discount-netPrice,
VKGRP: $.rule.priceGroupCode,
ZIDDO735_E1KOMG_QUANTITY: {
TDID_MIN_QTY: $.rule.quantities.minimum,
TDID_MAX_QTY: $.rule.quantities.maximum
},
ZIDDO735_E1KOMG: {
ZIDD0735_SHIP_TO_KUNWE: {
LAND1: $.rule.shipTo.country,
NAME1: $.rule.shipTo.name,
ORT01: $.rule.shipTo.city,
REGIO: $.rule.shipTo.region,
TELF1: $.rule.shipTo.phone as :string replace "-" with "",
ADRNR: $.rule.shipTo.addressNumber,
SPRAS: $.rule.shipTo.languageKey,
STRAS: $.rule.shipTo.streetAddress
},
(ZIDD0735_KNA1_DETAILS: $.rule.soldTo.*ZCOM_AGR_SOLD default [] map {
KUNNR: $.id,
LAND1: $.country,
NAME1: $.name,
ORT01: $.city,
PSTLZ: $.postalCode,
REGIO: $.region,
TELF1: $.phone as :string replace "-" with "",
ADRNR: $.addressNumber,
SPRAS: $.languageKey,
STRAS: $.streetAddress
}) when ($.rule.soldTo !="" and $.rule.soldTo.*ZCOM_AGR_SOLD as :object !="")
},
E1KONH: {
DATAB: $.rule.dates.validFrom as :dtfield replace "-" with "",
DATBI: $.rule.dates.validTo as :dtfield replace "-" with "",
E1KONP: {
KSCHL: $.rule.conditionType,
KRECH: $.rule.condition.calculationType,
KBETR: $.rule.condition.approved-discount-netPrice,
KONWA: $.rule.condition.unitOfMeasue,
ZAEHK_IND: $.rule.condition.conditionitemindex,
VALTG: $.rule.condition.additionalvaluedays,
VALDT: $.rule.condition.fixedvaluedate,
KLF_STG: $.rule.condition.numberOfIncrementalScale,
KLF_KAL: $.rule.condition.scaleNumberForPricing
}
}
}})
}
}
}
}
}
实际上发生了什么,输出xml的ZIDD0735_KNA1_DETAILS节点下的字段映射到ZCOM_AGR_SOLD下的字段,ZCOM_AGR_SOLD是数据列表,或者你可以说array.In输出我有ZCOM_AGR_SOLD的值,我在ZIDD0735_KNA1_DETAILS下获取数据,但不是ZIDD0735_KNA1_DETAILS的重复值,而是在ZIDD0735_KNA1_DETAILS下获得ZCOM_AGR_SOLD,所有输入xml节点名称都不输出节点名称。仅在此字段中发生这种情况。休息一切正常。
答案 0 :(得分:0)
这是一个类似的情况:
https://forums.mulesoft.com/questions/1108/dataweave-date-conversion-from-string.html
可能是您的日期是造成例外的日期吗?