Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有
网关 -> 链 -> http:outbound-gateway -> 变压器
对于网关,我有错误通道来处理来自出站网关的 400 个响应。
我在错误通道中获得的有效负载是MessageHandlingException。它没有办法检索响应正文。
有没有办法我可以将响应主体作为有效负载而不是异常。或者如果我可以得到响应体,有什么办法吗?
我的 400 响应有正文。
它没有在文档中详细说明,但它是可用的。有MessageHandlingException一个嵌套异常HttpClientErrorException。这已经捕获了响应主体以及其他有用信息。要提取响应正文,请调用payload.getCause().getResponseBodyAsString()
MessageHandlingException
HttpClientErrorException
payload.getCause().getResponseBodyAsString()