2
异常返回定制的响应我使用Apache的骆驼和JBoss导火索,我已经创造了如何在Apache的骆驼
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:camel="http://camel.apache.org/schema/blueprint"
xmlns:cxf="http://camel.apache.org/schema/blueprint/cxf"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
<cxf:rsServer address="/testservice" id="testserver" serviceClass="com.company.HelloBean">
<camelContext id="testContext" trace="false" xmlns="http://camel.apache.org/schema/blueprint">
<route id="testRoute" >
<from id="_from1" uri="cxfrs:bean:testserver"/>
<bean beanType="com.company.HelloBean"
id="_bean1" method="hello"/>
</route>
</camelContext>
</blueprint>
和Java类下面列出的样本路线蓝图实现它
@Path("/testservicenew")
public class HelloBean {
@POST
@Path("/test")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public String hello(Person name) {
return "Hello:"+name.getName();
}
}
但是当我错送JSON返回错误的请求,我有些自定义拦截器,所以我可以控制我的身体定制和头在返回的响应
随意进一步询问是否犯规清除它,我还没有编制,只是从我的旧项目复制它 –
谢谢我的理解 –