Exactly. Currently you are telling Camel that you want a String. That's why
you're not getting a POJO.

*Raúl Kripalani*
Apache Camel PMC Member & Committer | Enterprise Architect, Open Source
Integration specialist
http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
http://blog.raulkr.net | twitter: @raulvk

On Mon, Mar 31, 2014 at 9:36 AM, Sergey Beryozkin <sberyoz...@gmail.com>wrote:

> Hi,
> If you need CXF help converting the data into POJO then add
> DeltaRequestPOJO into the signature, instead of String/InputStream.
> This will work assuming a JAX-RS JSON provider is registered with the
> endpoint.
> Otherwise, if you prefer it done at the Camel level, then I guess you will
> need to set up Camel Data Format...
>
> Cheers, Sergey
>
> On 31/03/14 07:22, bijoy wrote:
>
>> Hi Sergey,
>>
>> Adding String and InputStream in the method signature making json data
>> available to exchange body but camel is not able to convert the json into
>> pojo. I'm using SimpleConsumer binding. I guess the problem is with
>> binding,
>> any idea?
>>
>> *camel-config.xml*
>> <camel:route id="httpRequest">
>>             <camel:from
>> uri="cxfrs://bean://restServer?bindingStyle=SimpleConsumer"/>
>>             <camel:to uri="log:?showAll=true"/>
>>             <camel:process ref="validateRequest"/>
>> </camel:route>
>>
>> *ValidateProcessor.java*
>> public void process(Exchange exchange) throws Exception {
>> String message = exchange.getIn().getBody(String.class);
>> System.out.println("JSON Message:"+message); //*proper json is displayed>*
>> DeltaRequestPOJO deltaReq =
>> exchange.getIn().getBody(DeltaRequestPOJO.class);
>> if (!deltaReq.getOrderId().isEmpty() && !deltaReq.getTimeStamp().
>> isEmpty())
>> // *getting null pointer here*
>>                         {
>>                                 //some logic
>>                         }
>>
>> *DeltaRequestPOJO.java*
>> @XmlRootElement(name = "createDeltaRequest")
>> public class DeltaRequestPOJO {
>>
>>         String orderId;
>>         String timeStamp;
>>          // then getters and setters
>>
>> *RestServices.java*
>>     @POST
>>      @Consumes("application/json")
>>      @Produces("application/json")
>>      @Path("/delta")
>>      public Response createDelta(String jsonData) {
>>          return null;
>>      }
>>
>>
>>
>> --
>> View this message in context: http://camel.465427.n5.nabble.
>> com/Issues-with-cxfrs-using-json-tp5749474p5749552.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
>
> --
> Sergey Beryozkin
>
> Talend Community Coders
> http://coders.talend.com/
>
> Blog: http://sberyozkin.blogspot.com
>

Reply via email to