apiKit路由器Mule4后多部分/表单数据中断



在请求通过Mule4应用程序中的ApiKit路由器后,从多部分/表单数据中读取数据时出现问题。

有一个RAML到位,用于ApiKit路由器验证&路由请求。

#%RAML 1.0 
title: ACC race data API
description: API for designing and updating race data
version: 1
protocols: [ HTTPS, HTTP ]
/acc/reverse/entrylist:
description: Used to manipulate entrylist for ACC reverse grid.
post:
description: Creates new entrylist based on supplied quali result, race one result and race one entrylist.
queryParameters:
positionsRotated:
description: Parameter defining how many positions to rotate.
required: false
type: number
example: 30
body:
multipart/form-data:
properties:
qualifyResult:
description: File containing qualifying result.
type: file
fileTypes: ['application/json']
required: true
raceOneResult:
description: File containing race 1 result.
type: file
fileTypes: ['application/json']
required: true

验证工作正常-如果数据以不正确的格式发送,则返回异常。对于正确格式化的数据,请求被路由到流CCD_ 1。在这些步骤之间,有效载荷格式(由Mule(从可读形式的有效载荷(见下文(更改为java.io.ByteArrayInputStream@379ebdd5

ApiKit路由器之前有效载荷数据的可读格式(接收到应用程序(:

----------------------------180928595588258919887097
Content-Disposition: form-data; name="qualifyResult"; filename="json1.json"
Content-Type: application/json
{
"json1": "1"
}
----------------------------180928595588258919887097
Content-Disposition: form-data; name="raceOneResult"; filename="json2.json"
Content-Type: application/json
{
"json2": "2"
}
----------------------------180928595588258919887097--

如果在apiKit之前使用,则以下dataweave脚本可以正常工作,但在apiKit调用的流中不起作用:

%dw 2.0
output application/json
---
payload.parts[1].content

如果在ApiKit:之前使用上述DW,则输出示例

{
"json2": "2"
}

输出示例,如果在ApiKit之后使用相同的DW:

org.mule.runtime.core.api.expression.ExpressionRuntimeException: "javax.mail.internet.ParseException - Missing start boundary, while reading `payload` as MultiPart.
Trace:
at main (Unknown)" evaluating expression: "%dw 2.0
output application/json
---
payload.parts[1].content".

Anypoint Studio 7.8.0中的测试,应该在Mule4 CE运行时完成并准备部署后使用。使用Postman v8.5.1进行测试。发送带有qualifyResult和raceOneResult部分的表单数据体,这些部分包含JSON数据、默认标头、基本身份验证、查询参数positionsRotated=30。调用的Url:https://localhost:443/api/acc/reverse/entrylist?positionsRotated=30尝试使用RAW类型的有效载荷手动生成多部分/表单数据体,但结果相同。如果没有ApiKit,一切都很好。。但我想用它来验证请求的有效性。

感谢大家回复任何有用的提示!

我在最新版本中测试了一个类似的场景,我没有遇到这个问题。如果您使用的是旧版本的HTTP连接器和APIKit模块,请尝试升级到最新版本。Anypoint Studio具有检测连接器的新版本的功能:https://docs.mulesoft.com/studio/7.9/update-modules

最新更新