Mule - How to do a choice/when based on http response codes?

半世苍凉 提交于 2019-12-02 09:41:15

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

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

Likewise in a Groovy script:

message.getInboundProperty('http.status')

Seba is right but that is not enough.

By default, if an client or server error is detected in an HTTP outbound interaction (ie response code >= 400), Mule will treat the response as an error and will break the flow execution and call the exception strategy to deal with the error.

You need to deactivate this behaviour before doing the HTTP outbound interaction in order to have the rest of the flow (your choice router) be called. So you need this:

<set-variable variableName="http.disable.status.code.exception.check"
              value="true" />

before your HTTP outbound endpoint.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!