mulesoft - Mulesoft - 捕获 http 状态
问题描述
调用一个肥皂网络服务并使用一个 groovy 脚本检查网络服务响应的 http 状态。在 Mule 3 中,groovy 脚本是...
def httpStatus = message.getInboundProperty('http.status')
if (httpStatus == '400') {
throw new Exception('Bad Request');
}
return payload;
Mule 4中的等价物是什么?谢谢。
解决方案
#[attributes.statusCode]
是 Mule 3 #[inboundProperties.'http.status] 的等效表达式(https://docs.mulesoft.com/connectors/http/http-request-ref#map-between-http-responses-and-mule-messages)。如果属性映射到 Mule 4 中的 Groovy 脚本,我不记得我的想法,您需要尝试一下。
我建议避免使用 Groovy 或其他脚本语言进行错误处理,而是使用 Mule 内置的错误处理。
推荐阅读
- java - 在 CPLEX for Java 中设置时间限制
- snowpack - snowpack:项目文件夹之外的参考文件
- python-3.x - 我应该在 Pytorch 的以下架构中将输入图像尺寸放在哪里?
- c++ - 使用`dlopen`时有关“未定义符号”的共享库错误
- netsuite - 此处应有一个选项,而不是在使用 sdfcli 命令验证或部署 SuiteApp 项目时返回的“T”
- python - UnicodeDecodeError:从 .txt 文件中读取西班牙语文本
- wxwidgets - wxOwnerDrawnComboBox-inherited 类不可聚焦
- linux - 将顶部输出重定向到文件时可以看到特殊字符
- java - 为什么我已经抛出未报告的异常 java.net.MalformedURLException?
- html - 如何使这些 div 响应任何设备?