Mule Dataweave错误:您调用了函数';值选择器';将Excel转换为JSON时使用这些参数

Mule Dataweave错误:您调用了函数';值选择器';将Excel转换为JSON时使用这些参数,mule,anypoint-studio,dataweave,Mule,Anypoint Studio,Dataweave,我正在使用Anypoint 7和Mule 4.1 我想从计算机上的文件夹中读取Excel(xlsx)文件并将其转换为JSON,但收到错误: 您使用以下参数调用函数“值选择器”: 我认为这是由于流媒体,但不知道如何修复它 谢谢你的帮助 XML: <?xml version="1.0" encoding="UTF-8"?> <mule xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:file="http

我正在使用Anypoint 7和Mule 4.1

我想从计算机上的文件夹中读取Excel(xlsx)文件并将其转换为JSON,但收到错误:

您使用以下参数调用函数“值选择器”:

我认为这是由于流媒体,但不知道如何修复它

谢谢你的帮助

XML:

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw"
    xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
    xmlns:ftp="http://www.mulesoft.org/schema/mule/ftp"
    xmlns:sftp="http://www.mulesoft.org/schema/mule/sftp" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/sftp http://www.mulesoft.org/schema/mule/sftp/current/mule-sftp.xsd
http://www.mulesoft.org/schema/mule/ftp http://www.mulesoft.org/schema/mule/ftp/current/mule-ftp.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd">
    <flow name="testFlow" doc:id="3030b14f-b215-4c85-a6a4-96236516c552" >
        <scheduler doc:name="Scheduler" doc:id="d0985a96-a23c-4e2c-80ae-d78a9acd938e" >
            <scheduling-strategy >
                <fixed-frequency timeUnit="SECONDS"/>
            </scheduling-strategy>
        </scheduler>
        <file:read doc:name="Read xlsx file" doc:id="90b40273-ec58-47de-a48b-9812c52a74ea" path="C:\apps\test-api\src\test\resources\input\myTestExcelFile.xlsx" config-ref="File_Config">
            <ee:repeatable-file-store-stream />
        </file:read>
        <ee:transform doc:name="Transform Message" doc:id="36dbec15-6e02-4fdf-8176-025ad7fdce61" >
            <ee:message >
                <ee:set-payload ><![CDATA[%dw 2.0
input payload application/xlsx
output application/json
---
payload.CUSTOMER map ( cUSTOMER , indexOfCUSTOMER ) -> {
    custId: cUSTOMER."Customer Code" default "",
    custName: cUSTOMER.Name default ""
}
]]></ee:set-payload>
            </ee:message>
        </ee:transform>
        <logger level="INFO" doc:name="Log Message" doc:id="5142b6ff-9d04-4cb2-ba3b-7fec5e52dd9b" message='#[payload]' category="com.test"/>
    </flow>
</mule>

{
客户ID:客户。“客户代码”默认为“”,
客户名称:客户名称默认值“”
}
]]>
错误消息

ERROR 2018-08-03 11:03:34,628 [[MuleRuntime].cpuLight.02: [test-api].testFlow.CPU_LITE @75c313f3] [event: 0-7a8a0890-9704-11e8-900d-a44cc83a8228] org.mule.runtime.core.internal.exception.OnErrorPropagateHandler: 
********************************************************************************
Message               : "You called the function 'Value Selector' with these arguments: 
  1: Binary
  2: Name ("CUSTOMER")

But it expects one of these combinations:
  (Array, Name)
  (Array, String)
  (Date, Name)
  (DateTime, Name)
  (LocalDateTime, Name)
  (LocalTime, Name)
  (Object, Name)
  (Object, String)
  (Period, Name)
  (Time, Name)

5| payload.CUSTOMER map ( cUSTOMER , indexOfCUSTOMER ) -> {
   ^^^^^^^^^^^^^^^^
Trace:
  at map (line: 5, column: 1)
  at main (line: 5, column: 18)" evaluating expression: "%dw 2.0
input payload application/xlsx
output application/json
---
payload.CUSTOMER map ( cUSTOMER , indexOfCUSTOMER ) -> {
    custId: cUSTOMER."Customer Code" default "",
    custName: cUSTOMER.Name default ""
}
".
Error type            : MULE:EXPRESSION
Element               : testFlow/processors/1 @ test-api:test.xml:21 (Transform Message)
Element XML           : <ee:transform doc:name="Transform Message" doc:id="36dbec15-6e02-4fdf-8176-025ad7fdce61">
<ee:message>
<ee:set-payload>%dw 2.0
input payload application/xlsx
output application/json
---
payload.CUSTOMER map ( cUSTOMER , indexOfCUSTOMER ) -> {
    custId: cUSTOMER."Customer Code" default "",
    custName: cUSTOMER.Name default ""
}</ee:set-payload>
</ee:message>
</ee:transform>

  (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
ERROR 2018-08-03 11:03:34628[[MuleRuntime].cpuLight.02:[test api].testFlow.CPU_LITE@75c313f3][event:0-7a8a0890-9704-11e8-900d-a44cc83a8228]org.mule.runtime.core.internal.exception.onerrorproadhandler:
********************************************************************************
消息:“您使用以下参数调用了函数‘值选择器’:
1:二进制
2:名称(“客户”)
但它预计会出现以下组合之一:
(数组,名称)
(数组,字符串)
(日期、姓名)
(日期时间、名称)
(LocalDateTime,名称)
(本地时间、名称)
(对象、名称)
(对象,字符串)
(句号、姓名)
(时间、姓名)
5 | payload.CUSTOMER映射(CUSTOMER,indexOfCUSTOMER)->{
^^^^^^^^^^^^^^^^
跟踪:
在地图上(行:5,列:1)
在main(第5行,第18列)“求值表达式:”%dw 2.0
输入有效负载应用程序/xlsx
输出应用程序/json
---
payload.CUSTOMER映射(客户,IndexOfcCustomer)->{
客户ID:客户。“客户代码”默认为“”,
客户名称:客户名称默认值“”
}
".
错误类型:MULE:EXPRESSION
元素:testFlow/processors/1@testapi:test.xml:21(转换消息)
元素XML:
%DW2.0
输入有效负载应用程序/xlsx
输出应用程序/json
---
payload.CUSTOMER映射(客户,IndexOfcCustomer)->{
客户ID:客户。“客户代码”默认为“”,
客户名称:客户名称默认值“”
}
(为所有内容设置调试级别日志或“-Dmule.verbose.exceptions=true”)
XLSX文件


我发现问题在于我没有将文件连接器上的MIME类型设置为application/xlsx

一旦我设置了这个,它就工作了