Apache camel 是否可以捕获单个使用者上的所有rest请求,并使用cxfrs转发到实际的rest web服务?
不是这样,我可以根据以下代码将单个消费者映射到单个rest服务: 路线配置:Apache camel 是否可以捕获单个使用者上的所有rest请求,并使用cxfrs转发到实际的rest web服务?,apache-camel,cxf,cxfrs,Apache Camel,Cxf,Cxfrs,不是这样,我可以根据以下代码将单个消费者映射到单个rest服务: 路线配置: <bean class="com.x.ws.integration.route.SampleRouteProcessor" id="sampleRouteProcessor" /> <camel:routeContext id="xyz"> <camel:route xmlns="http://camel.apache.org/schema/spring">
<bean class="com.x.ws.integration.route.SampleRouteProcessor"
id="sampleRouteProcessor" />
<camel:routeContext id="xyz">
<camel:route xmlns="http://camel.apache.org/schema/spring">
<camel:from
uri="cxfrs:bean:getSampleHoliDay?bindingStyle=SimpleConsumer" />
<camel:setHeader headerName="CamelHttpMethod">
<constant>GET</constant>
</camel:setHeader>
<camel:setHeader headerName="Content-Type">
<constant>application/json</constant>
</camel:setHeader>
<camel:setHeader headerName="accept">
<constant>application/json</constant>
</camel:setHeader>
<camel:to uri="cxfrs:bean:getSampleHoliDayClient" />
</camel:route>
</camel:routeContext>
<cxf:rsServer id="getSampleHoliDay" loggingFeatureEnabled="true"
serviceClass="com.nucleus.rest.consumer.RestConsumerImpl">
<cxf:providers>
<bean class="org.codehaus.jackson.jaxrs.JacksonJsonProvider" />
</cxf:providers>
</cxf:rsServer>
<!--Create receipt REST service Producer service client -->
<cxf:rsClient id="getSampleHoliDayClient"
address="http://10.*.*.*:*/sample-integration/rest/"
loggingFeatureEnabled="true">
<cxf:providers>
<bean class="org.codehaus.jackson.jaxrs.JacksonJsonProvider" />
</cxf:providers>
</cxf:rsClient>
得到
应用程序/json
应用程序/json
集成时的消费者:
import java.util.Map;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
@Path("/")
public interface RestConsumer
{
@GET
@Path("/getSampleRequest")
@Produces(MediaType.APPLICATION_JSON)
public Map<String, Object> getSampleResponse();
}
import java.util.Map;
导入javax.ws.rs.GET;
导入javax.ws.rs.Path;
导入javax.ws.rs.products;
导入javax.ws.rs.core.MediaType;
@路径(“/”)
公共接口使用者
{
@得到
@路径(“/getSampleRequest”)
@产生(MediaType.APPLICATION_JSON)
公共映射getSamplerResponse();
}
现在,如果我使用@Path(“/*”),它将不起作用。我想创建一个RestConsumer,它应该能够捕获所有rest请求并相应地转发 使用标准jetty http侦听器,然后将请求路由到不同的处理程序。您必须自己处理REST操作和映射,或者使用REST-DSL 请参见骆驼码头的“matchOnUriPrefix”设置: REST DSL: