使用Dataweave为“值选择器”运算符键入不匹配

时间:2016-10-16 02:56:49

标签: dataweave

我将数据映射器(将xml转换为POJO)迁移到数据编织。但是在执行流程时,我看到了以下异常

“值选择器”运算符的类型不匹配      发现:string,:name   required:datetime,:name或   required:localdatetime,:name或   required:object,:name或   要求:时间,:名称或   required:array,:name或   要求:日期,:名称或   必需:localtime,:name或   required:period,:name。

输入(Payload)是如下的XML:

<?xml version="1.0" encoding="UTF-8"?>
<RESPONSE_GROUP MISMOVersionID="2.4">
    <RESPONDING_PARTY/>
    <RESPOND_TO_PARTY/>
    <RESPONSE ResponseDateTime="2016-04-21T09:03:44-05:00">
        <KEY _Name="LSF.FloodRequestID" _Value="1604008485"/>
        <KEY _Name="LSF.MAPUPDATE" _Value="N"/>
        <KEY _Name="LSF.TrackingVendor" _Value="171"/>
        <KEY _Name="CLIENT.TRACKINGID" _Value="18786574"/>
        <KEY _Name="CLIENT.ID" _Value="CREDITCENTER"/>
        <RESPONSE_DATA>
            <FLOOD_RESPONSE FEMAAdditionalLenderDescription="98756987876" MISMOVersionID="2.4">
                <BORROWER _FirstName="###############" _LastName="###############"/>
                <MORTGAGE_TERMS LenderCaseIdentifier="068461451"/>
                <PROPERTY _City="MASON CITY" _County="CERRO GORDO" _PostalCode="50401" _State="IA" _StreetAddress="929 N ADAMS AVE">
                    <_IDENTIFICATION CountyFIPSCode="033" StateFIPSCode="19"/>
                </PROPERTY>
                <EMBEDDED_FILE MIMEType="application/pdf" _Description="Adobe Pdf" _EncodingType="Base64" _Extension="pdf" _Name="Certificate_1604008485" _Version="1.3">
                    <DOCUMENT>bae64encodedData</DOCUMENT>
                </EMBEDDED_FILE>
                <FLOOD_DETERMINATION FloodCertificationIdentifier="1604008485" FloodPartialIndicator="N" FloodProductCertifyDate="2016-04-05 08:21:24 AM" SpecialFloodHazardAreaIndicator="N" _LifeOfLoanIndicator="Y">
                    <_LOAN_INFORMATION RegulatoryAgencyLenderIdentifier="123456789"/>
                    <_COMMUNITY_INFORMATION NFIPCommunityFIRMDate="1980-12-02" NFIPCommunityIdentifier="190060" NFIPCommunityName="MASON CITY, CITY OF" NFIPCommunityParticipationStartDate="1975-03-21" NFIPCounty="CERRO GORDO" NFIPStateCode="IA"/>
                    <_BUILDING_INFORMATION NFIPFloodZoneIdentifier="X" NFIPMapIdentifier="19033C" NFIPMapIndicator="Y" NFIPMapPanelDate="2012-05-16" NFIPMapPanelIdentifier="0162" NFIPMapPanelSuffixIdentifier="C"/>
                    <_INSURANCE_INFORMATION NFIPCommunityParticipationStatusType="Regular" ProtectedAreaIndicator="N"/>
                    <FULFILLMENT_PARTY _City="Austin" _Name="CoreLogic Flood Services" _PostalCode="78758" _State="TX" _StreetAddress="11902 Burnet Road">
                        <CONTACT_DETAIL>
                            <CONTACT_POINT _RoleType="Work" _Type="Phone" _Value="1-800-447-1772"/>
                        </CONTACT_DETAIL>
                    </FULFILLMENT_PARTY>
                </FLOOD_DETERMINATION>
                <LENDER _City="Jacksonville" _Identifier="98756987876" _PostalCode="32256" _State="FL" _StreetAddress="9000 Southside Blvd, Bldg 100" _UnparsedName="Bank of America"/>
                <EXTENSION>
                    <EXTENSION_SECTION>
                        <EXTENSION_SECTION_DATA>
                            <FLOOD_DETERMINATION SplitDeterminationIndicator="N"/>
                        </EXTENSION_SECTION_DATA>
                    </EXTENSION_SECTION>
                </EXTENSION>
            </FLOOD_RESPONSE>
        </RESPONSE_DATA>
        <STATUS _Code="S0010" _Condition="Success" _Description="This is a TEST ORDER. It cannot be used for any purpose other than system testing. Section II.B.4 applies to all buildings on property described in Sec I.2.   THIS FLOOD DETERMINATION IS PROVIDED TO THE LENDER PURSUANT TO THE FLOOD DISASTER PROTECTION ACT.  IT SHOULD NOT BE USED FOR ANY OTHER PURPOSE." _Name="Complete"/>
    </RESPONSE>
</RESPONSE_GROUP>

和dw变换看起来像

%dw 1.0
%output application/java
---
{
    brwrFirstName: payload.RESPONSE_GROUP.RESPONSE.RESPONSE_DATA.FLOOD_RESPONSE.BORROWER.@"_FirstName",

    brwrLastName: payload.RESPONSE_GROUP.RESPONSE.RESPONSE_DATA.FLOOD_RESPONSE.BORROWER.@"_LastName" default '',

我在brwrFirstName看到错误:payload.RESPONSE_GROUP.RESPONSE.RESPONSE_DATA.FLOOD_RESPONSE

3 个答案:

答案 0 :(得分:4)

正如Chad所说,你应该发布你的输入和实际的mule XML(不仅仅是DW代码),这将有助于人们更好地理解它。

根据提供的信息,看起来有效载荷是一个字符串,DW说它不能应用“。”字符串上的选择器。这就是你得到的错误。选择器只能应用于错误中所述的类型。

现在您希望DW将您的字符串解释为XML并进行相应的解析。有时,DW不知道这样做。但是,您可以在有效内容上强制使用DW类型将字符串解释为XML。只需将下面的子元素与适当的mimeType一起添加到<dw:transform-message>元素。

<dw:input-payload  mimeType="application/xml"/>

这将强制DW将字符串解析为XML,并且您的应用程序应该在那时工作。您也可以将mimeType属性应用于<dw:input-variable>

mule xml文件中的完整DW示例:

<dw:transform-message doc:name="Transform Message">
  <dw:input-payload  mimeType="application/xml"/>
  <dw:set-payload>
        <![CDATA[%dw 1.0
%output application/java
---
{
    brwrFirstName: payload.RESPONSE_GROUP.RESPONSE.RESPONSE_DATA.FLOOD_RESPONSE.BORROWER.@"_FirstName",
    brwrLastName: payload.RESPONSE_GROUP.RESPONSE.RESPONSE_DATA.FLOOD_RESPONSE.BORROWER.@"_LastName" default ''    
}]]>
    </dw:set-payload>
</dw:transform-message>

答案 1 :(得分:2)

面临错误:

ERROR 2017-03-07 12:49:50,060 [[bulk_create_poc].HTTP_Listener_Configuration.worker.01] org.mule.exception.DefaultMessagingExceptionStrategy: 
Message               : Exception while executing: 
 payload.ns0#ResponseData_MT.*Item map {
 ^
Type mismatch for 'Value Selector' operator
     found :binary, :name
  required :datetime, :name or
  required :localdatetime, :name or
  required :object, :name or
  required :time, :name or
  required :array, :name or
  required :date, :name or
  required :localtime, :name or
  required :period, :name.

为解决方案添加以下代码段

<dw:input-payload  mimeType="application/xml"/>

在此处

<dw:transform-message doc:name="Transform Message" metadata:id="b12f4d65-2bb0-43e9-b775-c2077863ba48">
<dw:input-payload  mimeType="application/xml"/>
<dw:set-payload><![CDATA[ 

答案 2 :(得分:0)

添加mime类型的数据类型对我来说真的很有用

我遇到的错误:

ERROR 2017-03-07 12:49:50,060 [[bulk_create_poc] .HTTP_Listener_Configuration.worker.01] org.mule.exception.DefaultMessagingExceptionStrategy:

消息:执行时出现异常:  payload.ns0 #ResponseData_MT。* Item map {  ^ “值选择器”运算符的类型不匹配      发现:二进制,:名称   required:datetime,:name或   required:localdatetime,:name或   required:object,:name或   要求:时间,:名称或   required:array,:name或   要求:日期,:名称或   必需:localtime,:name或   required:period,:name。

****Resolution that worked for me :****