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 ACDCC11C6B for ; Tue, 16 Sep 2014 12:43:40 +0000 (UTC) Received: (qmail 45845 invoked by uid 500); 16 Sep 2014 12:43:40 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 45792 invoked by uid 500); 16 Sep 2014 12:43: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 45781 invoked by uid 99); 16 Sep 2014 12:43:39 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Sep 2014 12:43:39 +0000 X-ASF-Spam-Status: No, hits=4.5 required=5.0 tests=HTML_MESSAGE,SPF_SOFTFAIL,URI_HEX X-Spam-Check-By: apache.org Received-SPF: softfail (nike.apache.org: transitioning domain of flaroche@gmail.com does not designate 216.139.236.26 as permitted sender) Received: from [216.139.236.26] (HELO sam.nabble.com) (216.139.236.26) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 16 Sep 2014 12:43:14 +0000 Received: from [192.168.236.26] (helo=sam.nabble.com) by sam.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1XTs6C-00038F-Th for users@camel.apache.org; Tue, 16 Sep 2014 05:43:12 -0700 Date: Tue, 16 Sep 2014 05:43:12 -0700 (PDT) From: flaroche To: users@camel.apache.org Message-ID: In-Reply-To: <54135F45.1030707@gmail.com> References: <1410527281604-5756419.post@n5.nabble.com> <54135F45.1030707@gmail.com> Subject: Re: [CXF RS] CXF producers using HttpApi and URI substitutions MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_173863_8804244.1410871392915" X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_173863_8804244.1410871392915 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Sergey, I have a pull request ready for it, it was really nothing ;) What I don't see so well now is the opening of an adjustment request. Should I just submit the pull request with the comment in it or is it some more process more strict ? Best regards, Fran=C3=A7ois 2014-09-12 23:03 GMT+02:00 Sergey Beryozkin-3 [via Camel] < ml-node+s465427n5756457h30@n5.nabble.com>: > Hi Fran=C3=A7ois > > On 12/09/14 14:08, flaroche wrote: > > > Hi everyone, > > > > I had an error a few days ago, and after investigations, here's what it > was > > : > > > > I am calling an endpoint using cxfrs client with the http api. So I hav= e > > something like that in the DSL : > > > > .... > > .setHeader(CxfConstants.CAMEL_CXF_RS_USING_HTTP_API, constant(true)) > > .setHeader(Exchange.HTTP_PATH, simple("/endpoint/${header.myHeader}")) > > .setHeader(Exchange.HTTP_METHOD, constant(POST)) > > .to("cxfrs:bean:myClient") > > .... > > > > This usually works fine. > > > > I had a somewhat nasty error when someone did a copy paste of my server= , > > with the variable substitution style (something like > /endpoint/{myVariable}) > > > > at that point, ${header.myHeader} resolved to {myVariable}, thus the ur= l > the > > client will try to resolve is /endpoint/{myVariable}. When trying to > parse > > this URL, CXF will not be happy, since there is no value to replace wha= t > it > > thinks to be a variable, and will throw an IllegalArgumentException wit= h > > message Unresolved variables; only 0 value(s) given for 1 unique > > variable(s). > > > > After looking a bit in the code, I understood better what happens. > > > > In order to avoid that, it would be nice to use the mechanism of CXF to > > replace variables in URI. > > > > In the DSL, we would have something like : > > > > .... > > .setHeader(CxfConstants.CAMEL_CXF_RS_USING_HTTP_API, constant(true)) > > .setHeader(CxfConstants.CAMEL_CXF_RS_VAR_VALUES, > > simple("[${header.myHeader}]")) > > .setHeader(Exchange.HTTP_PATH, constant("/endpoint/{myVariable}")) > > .setHeader(Exchange.HTTP_METHOD, constant("POST")) > > .to("cxfrs:bean:myClient") > > .... > > > > This array would have to be retrieved in the > CxfRsProducer#invokeHttpClient > > (as it is done in the invokeProxyClient method) and passed all the way > to > > the UriBuilder in the WebClient. > > WebClient itself can not be constructed with a URI containing template > vars but its .path() method can take a path with templates alongside an > array of objects. > Another approach could be to use UriBuilder to resolve the templates > first and then create use the resolve address as an effective address to > get a factory bean. > The former option is probably simpler, the code there already does > > if (path !=3D null) { > client.path(path); > } > > Can you please open a minor enhancement request ? A patch would be > welcome too :-), should be few lines only, as you suggested, take the > array, and if it is available, pass it to the client.path() > > Thanks, Sergey > > > > > What do you think of it ? > > > > Best regards, > > > > Fran=C3=A7ois > > > > > > > > > > -- > > View this message in context: > http://camel.465427.n5.nabble.com/CXF-RS-CXF-producers-using-HttpApi-and-= URI-substitutions-tp5756419.html > > Sent from the Camel - Users mailing list archive at Nabble.com. > > > > > -- > Sergey Beryozkin > > Talend Community Coders > http://coders.talend.com/ > > Blog: http://sberyozkin.blogspot.com > > > ------------------------------ > If you reply to this email, your message will be added to the discussion > below: > > http://camel.465427.n5.nabble.com/CXF-RS-CXF-producers-using-HttpApi-and-= URI-substitutions-tp5756419p5756457.html > To unsubscribe from [CXF RS] CXF producers using HttpApi and URI > substitutions, click here > > . > NAML > > -- View this message in context: http://camel.465427.n5.nabble.com/CXF-RS-CXF-= producers-using-HttpApi-and-URI-substitutions-tp5756419p5756579.html Sent from the Camel - Users mailing list archive at Nabble.com. ------=_Part_173863_8804244.1410871392915--