我必须创建一个Fuse服务,然后调用外部服务提供者公开的REST服务。 Fuse服务将以XML格式接收请求,并在调用REST服务之前转换为查询字符串。
Fuse服务的示例请求XML -
<CustomerDetails>
<CustomerName>ABC</CustomerName>
<CustomerAge>28</CustomerAge>
<CustomerName>DEF</CustomerName>
<CustomerAge>54</CustomerAge>
<CustomerDetails>
REST服务使用键值参数中的请求,并以XML格式响应。
示例网址:
我尝试了很多搜索,但无法在网上找到任何教程。
有人可以提供有关如何使用cxf-rs组件实现保险丝服务的建议(最好是Spring DSL驼峰配置)
提前致谢..
答案 0 :(得分:0)
如果您只想将XML请求转换为url参数,则可以使用jaxb data format来解组请求并使用bean对象来设置URI请求参数。您不需要使用camel-cxf组件。
from("direct:start").unmarshal(jaxb).process(new Processor() {
public void process(Exchange exchange) throws Exception {
// get the request object
CustomerDetail request = exchange.getIn().getBody();
// Just mapping the request object into a query parameters.
String query = requestToParameter(request);
exchange.getIn().setHeader(Exchange.HTTP_QUERY, query);
// to remove the body, so http endpoint can send the request with Get Method
exchange.getIn().setBody(null);
}).to("https://www.customer.com/cust/api/v1/store/abc.xml");