You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Matteo Redaelli <ma...@libero.it> on 2010/03/01 16:13:32 UTC

Re: camel-http: basic authentication and query parameter "username"

The problem is that I should manage 2 "username" parameters!

1)the first is a query parameter add in the remote url: it will be used to
retreive info about that user 

2) but, for basic authentication, camel also requires a parameter with the
same name "username" ... and the username for the basic authentication is
always different from the username I need to put in the url query..




ychawla wrote:
> 
> Hi Matteo,
> Did you check out this link:
> 
> http://camel.apache.org/http.html
> 
> It has info on connecting using basic auth.  This example show a poll from
> google that you can adapt to meet your needs.  Below is polls your URL and
> then write the result to a file:
> 
> from("timer://foo?fixedRate=true&delay=0&period=10000")
>    
> .to("http://remoteserver.location/get_user_info.xml?username=matteo&password=matteosPassword")
>     .setHeader(FileComponent.HEADER_FILE_NAME,
> "get_user_info.xml").to("file:target/google");
> 
> or in Spring
> 
> <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"
> trace="true">
>     <route>
>         <from uri="direct:start"/>
>         <to
> uri="http://remoteserver.location/get_user_info.xml?username=matteo&amp;password=matteosPassword"/>
>         <to uri="mock:result"/>
>     </route>
> </camelContext>
> 
> Cheers,
> Yogesh
> 
> 
> Matteo Redaelli wrote:
>> 
>> Hello
>> 
>> With camel-http I'd like to retreive an xml document from an url like
>> 
>>  http://remoteserver.location/get_user_info.xml?username=matteo
>> 
>> BUT that url requires a basic authentication
>> 
>> where  do I have to set basic auth params (username and password) and
>> where my query parameter "username"?? I read about adding params in url
>> or setting up header variable Exchange.HTTP_QUERY ..
>> 
>> Thanks in advance
>> Matteo
>> http://www.redaelli.org
>> 
>> 
> 
> 

-- 
View this message in context: http://old.nabble.com/camel-http%3A-basic-authentication-and-query-parameter-%22username%22-tp27714288p27714426.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: camel-http: basic authentication and query parameter "username"

Posted by Willem Jiang <wi...@gmail.com>.
Hi Matteo,

Did you receive my reply mail and try the solution of setting the 
message header with the Exchange.HTTP_QUERY just like this ?

from("timer://foo?fixedRate=true&delay=0&period=10000")
.setHeader(Exchange.HTTP_QUERY, "username=YOUR_NAME")
.to("http://remoteserver.location/get_user_info.xml?username=matteo&password=matteosPassword")
 
.setHeader(FileComponent.HEADER_FILE_NAME,"get_user_info.xml").to("file:target/google");


Willem


Matteo Redaelli wrote:
> The problem is that I should manage 2 "username" parameters!
> 
> 1)the first is a query parameter add in the remote url: it will be used to
> retreive info about that user 
> 
> 2) but, for basic authentication, camel also requires a parameter with the
> same name "username" ... and the username for the basic authentication is
> always different from the username I need to put in the url query..
> 
> 
> 
> 
> ychawla wrote:
>> Hi Matteo,
>> Did you check out this link:
>>
>> http://camel.apache.org/http.html
>>
>> It has info on connecting using basic auth.  This example show a poll from
>> google that you can adapt to meet your needs.  Below is polls your URL and
>> then write the result to a file:
>>
>> from("timer://foo?fixedRate=true&delay=0&period=10000")
>>    
>> .to("http://remoteserver.location/get_user_info.xml?username=matteo&password=matteosPassword")
>>     .setHeader(FileComponent.HEADER_FILE_NAME,
>> "get_user_info.xml").to("file:target/google");
>>
>> or in Spring
>>
>> <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"
>> trace="true">
>>     <route>
>>         <from uri="direct:start"/>
>>         <to
>> uri="http://remoteserver.location/get_user_info.xml?username=matteo&amp;password=matteosPassword"/>
>>         <to uri="mock:result"/>
>>     </route>
>> </camelContext>
>>
>> Cheers,
>> Yogesh
>>
>>
>> Matteo Redaelli wrote:
>>> Hello
>>>
>>> With camel-http I'd like to retreive an xml document from an url like
>>>
>>>  http://remoteserver.location/get_user_info.xml?username=matteo
>>>
>>> BUT that url requires a basic authentication
>>>
>>> where  do I have to set basic auth params (username and password) and
>>> where my query parameter "username"?? I read about adding params in url
>>> or setting up header variable Exchange.HTTP_QUERY ..
>>>
>>> Thanks in advance
>>> Matteo
>>> http://www.redaelli.org
>>>
>>>
>>
> 


Re: camel-http: basic authentication and query parameter "username"

Posted by Willem Jiang <wi...@gmail.com>.
Hi,

Can you try to set the second username paramerters by setting the 
message header with name of Exchange.HTTP_QUERY?

Willem


Matteo Redaelli wrote:
> The problem is that I should manage 2 "username" parameters!
> 
> 1)the first is a query parameter add in the remote url: it will be used to
> retreive info about that user 
> 
> 2) but, for basic authentication, camel also requires a parameter with the
> same name "username" ... and the username for the basic authentication is
> always different from the username I need to put in the url query..
> 
> 
> 
> 
> ychawla wrote:
>> Hi Matteo,
>> Did you check out this link:
>>
>> http://camel.apache.org/http.html
>>
>> It has info on connecting using basic auth.  This example show a poll from
>> google that you can adapt to meet your needs.  Below is polls your URL and
>> then write the result to a file:
>>
>> from("timer://foo?fixedRate=true&delay=0&period=10000")
>>    
>> .to("http://remoteserver.location/get_user_info.xml?username=matteo&password=matteosPassword")
>>     .setHeader(FileComponent.HEADER_FILE_NAME,
>> "get_user_info.xml").to("file:target/google");
>>
>> or in Spring
>>
>> <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"
>> trace="true">
>>     <route>
>>         <from uri="direct:start"/>
>>         <to
>> uri="http://remoteserver.location/get_user_info.xml?username=matteo&amp;password=matteosPassword"/>
>>         <to uri="mock:result"/>
>>     </route>
>> </camelContext>
>>
>> Cheers,
>> Yogesh
>>
>>
>> Matteo Redaelli wrote:
>>> Hello
>>>
>>> With camel-http I'd like to retreive an xml document from an url like
>>>
>>>  http://remoteserver.location/get_user_info.xml?username=matteo
>>>
>>> BUT that url requires a basic authentication
>>>
>>> where  do I have to set basic auth params (username and password) and
>>> where my query parameter "username"?? I read about adding params in url
>>> or setting up header variable Exchange.HTTP_QUERY ..
>>>
>>> Thanks in advance
>>> Matteo
>>> http://www.redaelli.org
>>>
>>>
>>
>