Hi

I am trying to use RESTLET component to create a rest service. My
requirement is to 
1) pass the 2 parameters called "id" and "firstName" 
2) create a Object of Customer class and set its class variables id and Name
with above parameters
3) Return the customer object so that my SOAP UI shows up the XML
representation of the customer object.

My Camel Route file is as follows
*
<?xml version="1.0" encoding="UTF-8"?>


<beans xmlns="http://www.springframework.org/schema/beans";
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:amq="http://activemq.apache.org/schema/core";
        xmlns:jaxrs="http://cxf.apache.org/blueprint/jaxrs";
xmlns:cxf="http://camel.apache.org/schema/cxf";
        xsi:schemaLocation="
       http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
       http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd
       http://activemq.apache.org/schema/core
http://activemq.apache.org/schema/core/activemq-core.xsd
        http://cxf.apache.org/blueprint/jaxrs
http://cxf.apache.org/schemas/blueprint/jaxrs.xsd
         http://camel.apache.org/schema/cxf
http://camel.apache.org/schema/cxf/camel-cxf.xsd
       http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd";>


        <bean id="activemq"
class="org.apache.activemq.camel.component.ActiveMQComponent">
                <property name="brokerURL" 
value="failover:tcp://localhost:61616" />
        </bean>


        <camelContext xmlns="http://camel.apache.org/schema/spring";>


                <route id="ReturnXML">
                        <from 
uri="restlet:http://d-113063918:9192/demo?restletMethod=POST"; />
                        <to uri="bean:ProcessRestMessage" />

                </route>


        </camelContext>



        <bean id="ProcessRestMessage"
class="com.mycompany.restPOC.ProcessRestMessage" />


</beans>*

and my Java processor is as follows

package com.mycompany.restPOC;
*
import javax.ws.rs.core.Response;

import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.component.restlet.RestletConstants;
import org.apache.log4j.Logger;


public class ProcessRestMessage implements Processor {
        protected Logger log = Logger.getLogger(getClass());

        @Override
        public void process(Exchange exchange) throws Exception {
        
                Customer customer=new Customer();
        
        
                customer.setId("1");
                customer.setName("abc");
                
        
                log.info(customer.getId() + " " + customer.getName());
                
        
exchange.getIn().setBody(Response.ok().type("application/xml").entity(customer).build());
                
        }
}
*

When I push the data from SoapUI, I get following log in camel

[              Restlet-20381868] ProcessRestMessage             INFO  1 abc
Dec 09, 2014 2:49:46 PM org.restlet.engine.log.LogFilter afterHandle
INFO: 2014-12-09        14:49:46        10.132.146.177  -       -       9192    
POST    /demo
firstName=Reji&id=Mathews       200     0       0       0       
http://d-113063918:9192
Apache-HttpClient/4.1.1 (java 1.5)      -

And as response I get only following in SoapUI Output window
<data contentType="text/plain; charset=UTF-8" contentLength="0"></data>


Can you help me in arranging things so that I get xml equalient of customer
object?


Cheers
Reji



--
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-REstlet-Response-tp5760370.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to