即使有404响应,也要继续执行流程 [英] Keep executing flow even with a 404 response

查看:94
本文介绍了即使有404响应,也要继续执行流程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下http请求:

I have the following http request:

<http:request config-ref="FlowVarsHostAndPort" path="/rest/bpo/evento" method="POST" doc:name="Envia movimentacoes para Elaw Correspondente">
                    <http:request-builder>
                        <http:header headerName="Content-Type" value="application/json"/>
                    </http:request-builder>
                </http:request>

此服务位于foreach内部,当它返回200的罚款时,但是当它返回404时抛出异常,流程停止,我需要当该服务返回我404时,我查看有效负载并确定是否需要继续执行流程,我该如何实现?

This service is inside a foreach, when it returns 200 its fine, but when it returns 404 it throws an exception an the flow stops, i need that when the service returns me a 404 i look at the payload and determine if it needs to keep executing the flow, how can i achieve it?

我尝试使用catch异常策略,但是没有成功.

I tryed using the catch exception strategy but with no sucess.

ps:当我正在寻找不存在的资源时,该服务将返回404,这是响应的一个示例:

ps: The service will return 404 when i'm looking for a resource that is not there, one example of response:

{
  "processo": "0009843-63.2016.8.13.0301",
  "mensagem": "Não foi possivel encontrar o processo"
}

推荐答案

在进行HTTP调用之前,需要先禁用行为,以免引发状态代码异常.在这种情况下,我们可以使用状态代码查看来自HTTP的响应,并执行所需的逻辑.

Before HTTP call, need to disable the behavior such that status code exception don't throw. In this case we can view the response from HTTP with status code and do logic whatever is required.

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

以其他方式

如果仅希望限制为404.使用成功状态验证程序,对HTTP来说404是成功响应之一.

If you want to limit only for 404. Say to HTTP 404 is one of the success response by using SuccessStatusCode validator.

 <http:request config-ref="" path="/rest/bpo/evento" method="POST" doc:name="Envia movimentacoes para Elaw Correspondente">
                <http:request-builder>
                <http:header headerName="Content-Type" value="application/json"/>
                </http:request-builder>
            <http:success-status-code-validator values="200,404"/>
  </http:request>

参考: https://docs.mulesoft. com/mule-user-guide/v/3.7/http-request-connector .检查此参考URL中的HTTP Response validation部分.

Reference:https://docs.mulesoft.com/mule-user-guide/v/3.7/http-request-connector. Check HTTP Response validation part in this reference url.

这篇关于即使有404响应,也要继续执行流程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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