[英]Camel With Cxf and Routing
我正在對Camel-CXf集成進行一些研究,並對以下情況感到困惑。
所以我實現了一個休息端點
@Path("/authenticate")
public interface Sample {
@GET
@Path("/handshake")
@Produces(MediaType.TEXT_PLAIN)
public Response handshake();
@POST
@Path("/login")
@Consumes({MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML})
@Produces(MediaType.APPLICATION_JSON)
public Response login(LoginRequest request) throws JsonGenerationException, JsonMappingException, IOException;
}
並實現如下
public class SampleImpl implements Sample{
@Context
private HttpHeaders headers;
@Autowired
CamelContext context;
public Response handshake()
{
System.out.println("HandShake Executed Successfully");
return Response.status(Status.OK).entity("This is a Message after Routing").build();
}
public Response login(LoginRequest request) throws JsonGenerationException, JsonMappingException, IOException {
System.out.println("The Rquest objecr is Received "+request);
return Response.status(Status.OK).entity(mapper.writeValueAsString(request)).build();
}
}
路線
<camel:from uri="cxfrs:bean:SampleRestEndPoint?bindingStyle=SimpleConsumer"></camel:from>
將其路由到實現中。 但是由於實現返回響應對象,因此如何構建路由變得很困惑。
任何指針將不勝感激。
杜德,看看這個-http://bushorn.com/camel-cxf-geocoder-example/
上面的示例雖然不是REST,但是將CXF與Camel路由一起使用是相同的。
我將執行以下強制性步驟:
避免使用bean /自定義類-嘗試使用駱駝框架功能。
使用XML-Spring / Blueprint DSL
@GauthamHonnavara-這是一個帶有關聯處理器的JS Web服務的實現,但是它沒有關聯到端點的任何直接路由。我的問題還專門針對無法從wsdl生成服務類的JAX-RS。
假設這個用例是,您需要客戶調用端點,然后執行另外5個步驟,聯系另一個Web服務,等等,然后將響應發送回去。 上面的實現將響應發送回webservice實現bean本身。
因此,為避免這種情況,請與生產者使用者等創建一個簡單的接口,就像在我的問題中一樣,然后如果要注入Exchange(如果需要)並使用以下配置,則使每個方法都無效。
<!-- Created the CXF End Point For the Calls to Come IN -->
<cxf:rsServer id="RestEndPoint" address="/rest"
serviceClass="com.poc.camel.cxf.service.incoming.xxx"
loggingFeatureEnabled="true" loggingSizeLimit="20">
<cxf:providers>
<bean class="org.codehaus.jackson.jaxrs.JacksonJsonProvider" >
<!-- <constructor-arg ref="customObjectMapper" type="org.codehaus.jackson.map.ObjectMapper"/> -->
</bean>
</cxf:providers>
</cxf:rsServer>
技巧是使用服務類標記。 如果在那里提供了接口,則它不需要CXF的具體實現。
希望這可以幫助。 讓我知道
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.