Return-Path: X-Original-To: apmail-camel-users-archive@www.apache.org Delivered-To: apmail-camel-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 149A018526 for ; Mon, 15 Jun 2015 03:35:41 +0000 (UTC) Received: (qmail 70884 invoked by uid 500); 15 Jun 2015 03:35:40 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 70571 invoked by uid 500); 15 Jun 2015 03:35:40 -0000 Mailing-List: contact users-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@camel.apache.org Delivered-To: mailing list users@camel.apache.org Received: (qmail 70560 invoked by uid 99); 15 Jun 2015 03:35:40 -0000 Received: from Unknown (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 15 Jun 2015 03:35:40 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 9AD4AC0943 for ; Mon, 15 Jun 2015 03:35:39 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 4.287 X-Spam-Level: **** X-Spam-Status: No, score=4.287 tagged_above=-999 required=6.31 tests=[DKIM_ADSP_CUSTOM_MED=0.001, KAM_ASCII_DIVIDERS=0.8, NML_ADSP_CUSTOM_MED=1.2, SPF_SOFTFAIL=0.972, URIBL_BLOCKED=0.001, URI_HEX=1.313] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id cXrnwp_sceiA for ; Mon, 15 Jun 2015 03:35:30 +0000 (UTC) Received: from mbob.nabble.com (mbob.nabble.com [162.253.133.15]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with ESMTP id 6F800216F0 for ; Mon, 15 Jun 2015 03:35:30 +0000 (UTC) Received: from msam.nabble.com (unknown [162.253.133.85]) by mbob.nabble.com (Postfix) with ESMTP id D3342EF669F for ; Sun, 14 Jun 2015 20:35:46 -0700 (PDT) Date: Sun, 14 Jun 2015 20:35:28 -0700 (MST) From: "praneeth.purighalla" To: users@camel.apache.org Message-ID: <1434339328963-5768224.post@n5.nabble.com> Subject: Using cxfrs producer with a dynamic endpoint from a metadata file MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi All, I'm completely new to Camel. So please bear with this requirement of mine. I have a file that contains some metadata in XML. This metadata includes the URI of my external HTTP service along with authentication details to connect to the endpoint. I'm trying to build my camel route in such a way that I read the metadata file, retrieve all the relevant details like URI, username, password, etc and then invoke the URI. This is my routing code: --------------------------------------------------START from("file:src/data?fileName=metadata.xml&noop=true") .setProperty("username", xpath("/endpoint/authentication/username", String.class)) .setProperty("password", xpath("/endpoint/authentication/password", String.class)) .setProperty("uri", xpath("/endpoint/uri", String.class)) .process(new Processor() { @Override public void process(Exchange exchange) throws Exception { // set exchange pattern as InOut exchange.setPattern(ExchangePattern.InOut); Message inMessage = exchange.getIn(); // using the http central client API inMessage.setHeader(CxfConstants.CAMEL_CXF_RS_USING_HTTP_API, Boolean.TRUE); // set the Http method inMessage.setHeader(Exchange.HTTP_METHOD, "GET"); // set authorization header String username = exchange.getProperty("username", String.class); String password = exchange.getProperty("password", String.class); inMessage.setHeader("Authorization", "Basic " + base64Encode(username + ":" + password)); exchange.getIn().setBody(""); CxfRsEndpoint myCxfEp = (CxfRsEndpoint) getContext().getEndpoint(exchange.getProperty("uri", String.class)); ProducerTemplate template = getContext().createProducerTemplate(); Exchange response = template.send(myCxfEp, exchange); exchange.getIn().setBody(response.getIn().getBody()); } private String base64Encode(String input) { return Base64Utility.encode(input.getBytes()); } }) .to("file:src/data/outbox"); --------------------------------------------------------END I want to capture the response from the external HTTP service into a file. When I sniff the request using TCPMON, I can see the expected request and response. However, the exchange object that gets written to the outbox in my final route node is still the metadata file in my "from" endpoint. Can someone help me with this? Am I doing something wrong or is there a better/easier way to achieve this? Here is a snippet of my metadata file: -------------------------START cxfrs://http://localhost:1111/test foo bar -------------------------END Thanks in advance, Praneeth -- View this message in context: http://camel.465427.n5.nabble.com/Using-cxfrs-producer-with-a-dynamic-endpoint-from-a-metadata-file-tp5768224.html Sent from the Camel - Users mailing list archive at Nabble.com.