我从uri获取id,并在将结果转换为XML格式后将其作为条件放入我的sql请求中。
这是函数:
package com.mycompany.camel.blueprint;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
public class Testws {
@GET
@Path("/test/{id}")
@Produces(MediaType.APPLICATION_XML)
public Integer getAssets(@PathParam("id") int id){
return id;
}
}这是路由:
<camelContext id="camel" xmlns="http://camel.apache.org/schema/blueprint">
<route>
<from uri="cxfrs://bean://rsServer"/>
<log message="${body}"/>
<convertBodyTo type="java.lang.Integer"/>
<to uri="sql:select * from customers where id=:#${body}?exchangePattern=InOut&dataSource=moodleDB"/>
</route> </camelContext>之后的错误:http://localhost:5070/route/test/1
This page contains the following errors:
error on line 1 at column 1: Document is empty
Below is a rendering of the page up to the first error.如何获取xml文档?谢谢?
发布于 2015-10-12 03:52:54
要使用cxfrs从camel路由返回xml,您需要一些东西:
XmlRootElement在类和其他批注中注解的customer对象,用于告诉jaxb如何编组它
服务器id="rsServer“address="${url}">
您需要将来自SQL调用的响应处理为一个customer对象列表,然后cxf可以使用该提供程序将其编组为xml。
您需要依赖jackson-jaxrs-xml-provider才能使用它。
https://stackoverflow.com/questions/32267728
复制相似问题