1
<cxf:rsServer id="rsServer" address="/services"
serviceClass="com.mayank.restservice.resource.RestfulResource">
<cxf:providers>
<bean class="org.codehaus.jackson.jaxrs.JacksonJsonProvider" />
<bean class="org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider" />
</cxf:providers>
</cxf:rsServer>
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="cxfrs:bean:rsServer" />
<to uri="log:body?level=INFO" />
<to uri="activemq:queue:testQueue" pattern="InOnly" />
</route>
</camelContext>
<!-- ActiveMQ-beans definition -->
<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
<property name="brokerURL" value="tcp://localhost:61616" />
</bean>
我已經實現了用駱駝CXF組件支持路由到ActiveMQ的隊列中的響應REST服務。現在,當運行服務url我得到沒有消息正文編寫器已發現類org.apache.cxf.message.MessageContentsList,ContentType:application/xml 消息。沒有消息體的作家已經發現了類org.apache.cxf.message.MessageContentsList,則contentType:應用程序/ XML
Below is my RestResource class.
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import com.mayank.restservice.model.ChequeDetails;
import com.mayank.restservice.service.RestfulService;
public class RestfulResource {
private RestfulService restfulservice;
public void setRestfulservice(RestfulService restfulservice) {
this.restfulservice = restfulservice;
}
@Path("post")
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_XML)
public ChequeDetails persistDB(ChequeDetails chequedetails){
return restfulservice.persistDB(chequedetails);
}
}
對於當我嘗試使用@Produce(APPLICATION_JSON)時進行測試,我得到了成功響應。 不知道這是從camel-cxf或我的應用程序中的問題嗎?