0
votes

I am new to apache camel and restlet component.

I am trying to receive a POST request from rest url and validate them using POJO bean.

I have the below route using Apache camel xml-dsl restlet component.

      <route>
        <from uri="restlet:/members?restletMethod=POST"/>
        <!--    <to uri="registerMemberBean"/>-->
        <bean ref="registerMemberBean" method="registermember"/>
    </route>

Basically, I am trying to POST to the /members url. I want to receive them in the POJO bean and/or invoke the specified method in POJO bean which should proceed the values received. Then, I would like to validate the values in the bean before passing to db.

I have tried using both the ways as above. I always see the error "org.apache.camel.RuntimeExchangeException: IllegalArgumentException occurred invoking method: ". ublic java.lang.String org.sample.service.RegisterMemberBean.regi sterMember(int,java.lang.String) using arguments: [null, null] on the exchange: Exchange[Message: [Body is null]]`` at org.apache.camel.component.bean.MethodInfo.invoke(MethodInfo.java:412

Also, I see in the stacktrace that BodyType and also Body is null.

Can someone help on this.

1

1 Answers

0
votes

I think the problem is your method. It looks like camel can not convert the exchange and/or body to the params you have specified. Can you please try this:

public void registermember(Exchange exchange){
  System.out.println("Body: " + exchange.getIn().getBody());
}

You should now see the body content and you can break there with a debugger to see what kind of class the body is.