I have a Camel route which accesses a REST service. Things work ok if the REST response is 200 ok. However, if the response is 404, the REST service returns some additional info in the payload, which I cannot find a way to access.
This is part of a debug log from running it:
[Camel (rraaCamelContext) thread #2 - seda://from_rraa] INFO org.apache.cxf.interceptor.LoggingInInterceptor - Inbound Message
----------------------------
ID: 2
Response-Code: 404
Encoding: ISO-8859-1
Content-Type: application/json
Headers: {Accept=[application/json], breadcrumbId=[ID-Steves-MacBook-Pro-local-53701-1446241733043-1-7], content-type=[application/json], OriginalHeader=[{name=VerifyEmployeeRequest, version=1, scac=rraa, timeSent=null, uuid=abcd-1234}], pin=[1234], reason=[INIT], Server=[Jetty(9.2.11.v20150529)], transfer-encoding=[chunked], User-Agent=[Apache CXF 3.1.2]}
Payload: { "employeeID": "bad-name", "message": "id not found" }
My route is set up as:
<route id="rraaIss">
<from uri="seda:from_rraa"/>
<process ref="issPreprocessor"/>
<unmarshal ref="IssRequest"/>
<process ref="webServiceProcessor"/>
<to uri="cxfrs:bean:webService"/>
<onException>
<exception>javax.ws.rs.NotFoundException</exception>
<handled><constant>true</constant></handled>
<to uri="bean:crewServiceNotFoundProcessor"/>
</onException>
<process ref="packageWebServiceReplyForIss"/>
<to uri="seda:to_rraa"/>
</route>
My crewServiceNotFoundProcessor
bean gets called when the response is 404 and it can see the exception, but how can I get the payload from the original HTTP response?
答案 0 :(得分:0)
我现在有这个工作。主要问题是我将REST操作定义为:
@GET
@Path(value="/authentication/{scac}/employees/{id}")
@Produces({ MediaType.APPLICATION_JSON })
public String verifyEmployee(@PathParam("scac") String scac,
@PathParam("id") String id,
@QueryParam("pin") String pin,
@QueryParam("reason") String reason);
当我将返回类型从String更改为Response时,现在可以使用完整的Response,并且throwExceptionOnFailure = false选项现在也可用。所以,这是一个新手错误。