From issues-return-49020-archive-asf-public=cust-asf.ponee.io@camel.apache.org Thu Feb 1 11:05:12 2018 Return-Path: X-Original-To: archive-asf-public@eu.ponee.io Delivered-To: archive-asf-public@eu.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by mx-eu-01.ponee.io (Postfix) with ESMTP id 2AAC8180652 for ; Thu, 1 Feb 2018 11:05:12 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 1A5C8160C44; Thu, 1 Feb 2018 10:05:12 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 614E6160C26 for ; Thu, 1 Feb 2018 11:05:11 +0100 (CET) Received: (qmail 8412 invoked by uid 500); 1 Feb 2018 10:05:10 -0000 Mailing-List: contact issues-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list issues@camel.apache.org Received: (qmail 8403 invoked by uid 99); 1 Feb 2018 10:05:10 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Feb 2018 10:05:10 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 280541A6493 for ; Thu, 1 Feb 2018 10:05:10 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -102.311 X-Spam-Level: X-Spam-Status: No, score=-102.311 tagged_above=-999 required=6.31 tests=[RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id 0l_O4PtypvM2 for ; Thu, 1 Feb 2018 10:05:05 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 575DD5F6D2 for ; Thu, 1 Feb 2018 10:05:02 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 9DF37E012F for ; Thu, 1 Feb 2018 10:05:01 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 143A421E88 for ; Thu, 1 Feb 2018 10:05:01 +0000 (UTC) Date: Thu, 1 Feb 2018 10:05:01 +0000 (UTC) From: "Claus Ibsen (JIRA)" To: issues@camel.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (CAMEL-12217) Camel REST DSL API - Multiple Content Type - XML Error MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CAMEL-12217?page=3Dcom.atlassia= n.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D163= 48327#comment-16348327 ]=20 Claus Ibsen commented on CAMEL-12217: ------------------------------------- Getting JAXB to work with jaxb.index files can be a bit tricky sometimes > Camel REST DSL API - Multiple Content Type - XML Error > ------------------------------------------------------ > > Key: CAMEL-12217 > URL: https://issues.apache.org/jira/browse/CAMEL-12217 > Project: Camel > Issue Type: Bug > Components: camel-core, camel-jaxb, camel-servlet > Affects Versions: 2.20.1, 2.20.2 > Environment: * Windows 10 > * JVM 1.8 > * IntelliJ IDEA > * Maven 3.3.3 > Reporter: Rafael Manzoni > Priority: Major > Fix For: 2.21.0 > > Attachments: credits-v1.zip > > > I am trying to create a Camel REST service via Java DSL that can consume/= produce both json and xml and the JSON works but I receive the an error whe= n I try to retrieve the result in XML. > RestConfiguration: > {code:java} > /** > * This configuration is for start the Apache Camel application with the = Spring Boot servlet > * @author rafael.manzoni > */ > public class RestConfiguration extends RouteBuilder { > @Override > public void configure() throws Exception { > restConfiguration() > .component("servlet") > .contextPath("/credits/v1") > .enableCORS(true) > .apiContextPath("/api-doc") > .apiProperty("api.title", "REST API") > .apiProperty("api.version", "v1") > .apiContextRouteId("doc-api") > .bindingMode(RestBindingMode.auto) > .dataFormatProperty("prettyPrint", "true") > .dataFormatProperty("mustBeJAXBElement", "true"); > } > }{code} > RestMethods: > {code:java} > /** > * Rest methods configuration. Apply all HTTP routes to Camel Routes > * @author REST Methods Configuration > */ > public class RestMethods extends RouteBuilder { > @Override > public void configure() throws Exception { > rest() > .bindingMode(RestBindingMode.auto) > .consumes("application/json, application/xml") > .produces("application/json, application/xml") > .get("/rating") > .toD("direct:getRatingByClient"); > } > }{code} > =C2=A0 > Route Implementation: > {code:java} > public class GetRatingByClientRoute extends RouteBuilder{ > // Use to created the mock > private final ObjectMapper objectMapper =3D new ObjectMapper(); > @Override > public void configure() throws Exception { > =20 > from("direct:getRatingByClient") > // Request > .to("log:init") > // Mediation > .process(exchange -> { > // TODO Implement route > TestEntity test =3D new TestEntity(); > test.setTestAttribute("Teste"); > exchange.getIn().setBody(test); > }) > // Response > .to("log:end"); > =20 > } > }{code} > When I run with Content-Type application/json works like a charm. But, wh= en i run with Content-Type application/xml i got this error:=C2=A0*_java.io= .IOException: org.apache.camel.InvalidPayloadException: No body available o= f type: javax.xml.bind.JAXBElement but has value: class GetRatingByClientRo= uteResponse_* > Follow the requisition that I=C2=B4m testing: > _*Success:*_ > curl -X GET \ '[http://localhost:8080/credits/v1/rating?client_cpf_cnpj= =3D11111111111]' \ -H 'Accept: application/json' \ -H 'Cache-Control: no-ca= che' \ -H 'Content-Type: application/json' > =C2=A0 > _*Failure:*_ > curl -X GET \ '[http://localhost:8080/credits/v1/rating?client_cpf_cnpj= =3D11111111111]' \ -H 'Accept: application/xml' \ -H 'Cache-Control: no-cac= he' \ -H 'Content-Type: application/xml' > =C2=A0 > I=C2=B4m attaching the project to this issue. -- This message was sent by Atlassian JIRA (v7.6.3#76005)