Rajeshwar
Rajeshwar

Reputation: 381

@pathparam along with POST payload for apache-cxf webservice

My interface that is implemented by my impl class looks something like this

@POST
@Path("/callA/{A}")
public FObj invokeA(@PathParam("A") int a,FObj fobj);

And my customRouteBuilder is routing the request to the above exposed service

.choice().when().simple("${header.operationName} == 'CallA'")
        .to("bean:BeanA?method=invokeA")

But when I hit the service from Rest client by setting the object from payload and also path param i get 500 Internal server error.

org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange Caused by: org.apache.camel.InvalidPayloadException: No body available of type: int but has value: com.dev.tp.FObj

Upvotes: 0

Views: 559

Answers (1)

Rostislav V
Rostislav V

Reputation: 1798

When you hit the service, a value to be set to header.operationName would be invokeA, if you are using CXFRS Component (i guess you are). @PathParam is from jaxrs specification. Camel knows nothing about it. When you invoke a method with two parameters, it tries to cast body payload to first parameter, and you see an exception.

I recomment you to take a look at this article

Upvotes: 0

Related Questions