我构建了一个API项目,该项目根据发送到API的参数来构建并将SOAP请求发送到另一个服务。当我们的生产和开发Mule环境为3.8.0 EE时,我无意间在Mule 3.9.0 EE中构建了该项目。该项目在3.9.0中可以在本地正常运行,并且可以在3.8.0中运行,直到在Dataweave中构建请求为止。它在3.8.0中报告以下异常:
Root Exception stack trace:
com.mulesoft.weave.engine.ast.dynamic.UnexpectedOperationTypesException: Type mismatch for 'mapObject' operator
found :array, :function
required :object, :function
我使用两个Dataweaves来构建请求。第一个从参数构建SOAP请求中使用的提示。第二个构建SOAP请求并插入提示。
第一个Dataweave:
%dw 1.0
%output application/json
---
[flowVars.parameterMap mapObject (value, key)->{
PROMPT: {
PSQueryName: "",
UniquePromptName: key,
FieldValue: value
}
}]
第二个Dataweave:
%dw 1.0
%output application/xml encoding="UTF-8"
%namespace SOAP-ENV http://schemas.xmlsoap.org/soap/envelope/
%namespace wsse http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd
%namespace qas http://xmlns.oracle.com/Enterprise/Tools/schemas/QAS_EXEQRY_SYNC_REQ_MSG.VERSION_1
%namespace qas1 http://xmlns.oracle.com/Enterprise/Tools/schemas/QAS_EXEQRY_SYNC_REQ.VERSION_1
---
{
SOAP-ENV#Envelope: {
SOAP-ENV#Header: {
wsse#Security @(SOAP-ENV#mustUnderstand: "1"): {
wsse#UsernameToken: {
wsse#Username: "someUsername",
wsse#Password @(Type: "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText"): "somePassword"
}
}
},
SOAP-ENV#Body: {
qas#QAS_EXEQRY_SYNC_REQ_MSG: {
qas1#QAS_EXEQRY_SYNC_REQ: {
QueryName: flowVars.queryName,
isConnectedQuery: "N",
OwnerType: flowVars.queryType,
BlockSizeKB: 0,
MaxRow: 0,
OutResultType: "webrowset",
OutResultFormat: "nonfile",
PROMPTS: payload.*PROMPT mapObject {
PROMPT: {
PSQueryName: $.PSQueryName when $.PSQueryName != "" otherwise {},
UniquePromptName: $.UniquePromptName,
FieldValue: $.FieldValue
}
}
}
}
}
}
}
在3.9.0中,Dataweave完美地转换了SOAP请求。在3.8.0中,它与第二个DataWeave中的PROMPTS: payload.*PROMPT mapObject
语句有关。
3.9.0中的哪些更改使此功能正常运行?
在3.8.0中如何解决此问题?
答案 0 :(得分:0)
我通过结合两个Dataweave自行解决了这一问题,事实证明将这两个数据分开是不必要的。
它无法回答3.9.0中发生的更改,从而使其可以在原始项目中工作。
%dw 1.0
%output application/xml encoding="UTF-8"
%namespace SOAP-ENV http://schemas.xmlsoap.org/soap/envelope/
%namespace wsse http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd
%namespace qas http://xmlns.oracle.com/Enterprise/Tools/schemas/QAS_EXEQRY_SYNC_REQ_MSG.VERSION_1
%namespace qas1 http://xmlns.oracle.com/Enterprise/Tools/schemas/QAS_EXEQRY_SYNC_REQ.VERSION_1
---
{
SOAP-ENV#Envelope: {
SOAP-ENV#Header: {
wsse#Security @(SOAP-ENV#mustUnderstand: "1"): {
wsse#UsernameToken: {
wsse#Username: "someUser",
wsse#Password @(Type: "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText"): "somePassword"
}
}
},
SOAP-ENV#Body: {
qas#QAS_EXEQRY_SYNC_REQ_MSG: {
qas1#QAS_EXEQRY_SYNC_REQ: {
QueryName: flowVars.queryName,
isConnectedQuery: "N",
OwnerType: flowVars.queryType,
BlockSizeKB: 0,
MaxRow: 0,
OutResultType: "webrowset",
OutResultFormat: "nonfile",
PROMPTS: flowVars.parameterMap mapObject (value, key)->{
PROMPT: {
PSQueryName: "",
UniquePromptName: key,
FieldValue: value
}
}
}
}
}
}
}