2015-10-30 53 views
2

我有一个访问REST服务的骆驼路由。事情工作正常,如果REST响应是200好的。但是,如果响应是404,则REST服务会返回有效负载中的一些其他信息,而我无法找到访问方式。如何从Camel cxfrs中的REST 404响应中访问有效内容?

这是从运行它的调试日志的一部分:

[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" } 

我的路线设置为:

<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> 

crewServiceNotFoundProcessor豆被调用时,响应404它可以看到异常,但是我怎样才能从原始的HTTP响应中获得有效载荷?

回答

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); 

当我改变了返回类型从字符串成响应,完全缓解现已有售,并且throwExceptionOnFailure = false选项现在工作也。所以,这是一个新手的错误。