骡子 - 如何基于http响应代码做出选择/何时? [英] Mule - How to do a choice/when based on http response codes?

查看:155
本文介绍了骡子 - 如何基于http响应代码做出选择/何时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要能够根据从http出站端点返回的http响应代码执行某些操作。例如,如果我得到500错误或302重定向或200.我需要一种方法来评估500,302,200。我知道如何使用Choice-When,但不知道如何使用如何访问响应代码groovy或你建议的任何内容。

I need to be able to perform certain actions based on the http response code I get back from an http outbound endpoint. For instance if I get a 500 error or a 302 redirect or a 200. I need a way to evaluate the 500, 302, 200. I know how to use Choice-When, but don't know how to access the response code using groovy or whatever you suggest.

推荐答案

你可以在HTTP出站终点之后立即获得带有以下表达式的HTTP响应代码: / p>

You can get the HTTP response code with the following expression right after the HTTP outbound endpoint:

#[message.inboundProperties['http.status']]

同样在Groovy脚本中:

Likewise in a Groovy script:

message.getInboundProperty('http.status')

这篇关于骡子 - 如何基于http响应代码做出选择/何时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆