【发布时间】:2018-04-03 16:02:56
【问题描述】:
有没有办法在 camel + spring-ws 中返回自定义主体(例如自定义 bean)和 http 状态为 500?
我试过了
onException(RuntimeException.class).handled(true).process(new
ExceptionProcessor()).marshal(jaxb);
然后在处理器中 公共类 ExceptionProcessor 实现处理器 {
@Override
public void process(Exchange exchange) throws Exception {
RuntimeException e = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, RuntimeException.class);
ExceptionHandler handler = ExceptionHandlerFactory.fromException(e);
ExceptionType response = handler.handleException();
if (exchange.hasOut()) {
exchange.getOut().setBody(response);
} else {
exchange.getIn().getHeaders();
exchange.getIn().setFault(true);
exchange.getIn().setBody(response);
}
}
}
但即使body是我想要的,http状态总是200。
你能帮助我吗?
更多信息: 我使用的是骆驼版本 2.20.2
【问题讨论】:
标签: apache-camel spring-ws spring-camel