You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by cacert <ka...@gmail.com> on 2016/08/29 18:18:43 UTC
http 415 error in cxf rest service
I am trying to build some rest and soap services using camel cxf-rs module.
Soap part is fine, in rest part i have one GET and one POST methods with
following signature. GET method working fine but POST method(which expects a
customer json object ) get HTTP status of 415 with error "No message body
reader has been found for class".Can anybody tell what is missing here ?
Rest interface:
@WebService
@Path("/bookstore")
@Consumes("application/json")
@Produces("application/json")
public interface BookStore {
@WebMethod
@GET
@Path("/{id}")
@Consumes("*/*")
Book getBook(@PathParam("id") @WebParam(name = "id") Long id) throws
Exception;
@WebMethod
@POST
@Path("/books")
Book addBook(@WebParam(name = "book") Book book);
}
PS: Here is the sample curl command:
curl -H "Content-Type: application/json" -X POST -d
'{"name":"xyz","isbn":"xyz"}'
http://localhost:8080/api/servlet/rest/bookstore/books
--
View this message in context: http://camel.465427.n5.nabble.com/http-415-error-in-cxf-rest-service-tp5786955.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: http 415 error in cxf rest service
Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi Brad
Thanks, FYI explicitly configuring CXF JSONProvider with a property
unmarshalAsJaxbElement may fix it or adding Jackson provider (while
excluding a jettison dependency) should work...
Cheers, Sergey
On 30/08/16 03:01, Ranx wrote:
> I assume you have a JSONProvider configured? That usually causes the error
> you are seeing.
>
> Does your Book class have an @XmlRootElement at its top? If you're using
> JAXB that is required even for JSON.
>
> Brad
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/http-415-error-in-cxf-rest-service-tp5786955p5786966.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
Re: http 415 error in cxf rest service
Posted by cacert <ka...@gmail.com>.
hi, as you said i could be able to solve this by defining a json
provider.thank you.
--
View this message in context: http://camel.465427.n5.nabble.com/http-415-error-in-cxf-rest-service-tp5786955p5787009.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: http 415 error in cxf rest service
Posted by Ranx <br...@mediadriver.com>.
I assume you have a JSONProvider configured? That usually causes the error
you are seeing.
Does your Book class have an @XmlRootElement at its top? If you're using
JAXB that is required even for JSON.
Brad
--
View this message in context: http://camel.465427.n5.nabble.com/http-415-error-in-cxf-rest-service-tp5786955p5786966.html
Sent from the Camel - Users mailing list archive at Nabble.com.