79.6.3. 简单绑定 Style 的更多示例

使用此方法获得 JAX-RS 资源类:

@POST @Path("/customers/{type}")
public Response newCustomer(Customer customer, @PathParam("type") String type, @QueryParam("active") @DefaultValue("true") boolean active) {
    return null;
}

由以下路由提供服务:

from("cxfrs:bean:rsServer?bindingStyle=SimpleConsumer")
    .recipientList(simple("direct:${header.operationName}"));

from("direct:newCustomer")
    .log("Request: type=${header.type}, active=${header.active}, customerData=${body}");

以下带有 XML 有效负载的 HTTP 请求(假设客户 DTO 为 JAXB-annotated):

POST /customers/gold?active=true

Payload:
<Customer>
  <fullName>Raul Kripalani</fullName>
  <country>Spain</country>
  <project>Apache Camel</project>
</Customer>

将打印信息:

Request: type=gold, active=true, customerData=<Customer.toString() representation>

有关如何处理请求和写入响应的更多示例,可在此处找到