You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by atg roxx <at...@gmail.com> on 2012/07/06 18:45:36 UTC

dynamically setting Registry based options messageSender

Hi Team,

I have some un usual requirement.


I have to send spring-ws request to third party which require two level of
authentication (server+application)

I have overridden the CommonsHttpMessageSender for it as shown below.
----------------
<bean id="messageSenderTest"
class="com.estar.eif.sbe.helper.TestCommonsHttpMessageSender">
        <constructor-arg index="0" ref="httpClient" />
        <constructor-arg index="1" value="${request.header.username.gb}" />
        <constructor-arg index="2" value="${request.header.password.gb}" />
        <property name="credentials">
            <bean
class="org.apache.commons.httpclient.UsernamePasswordCredentials">
                <constructor-arg index="0" value="${username}" />
                <constructor-arg index="1" value="$password}" />
            </bean>
        </property>
        <property name="connectionTimeout" value="${connectiontimeout}" />
        <property name="readTimeout" value="${readtimeout}" />
    </bean>
------------

and I am using the Dynamic registry based option messageSender  like this
--------------
 "?messageFactory=#messageFactory&messageSender=#messageSenderTest
-------------------

And it is working perfectly fine :).

Now the issue is, there is requirement change from our client that he want
to us to send different username/password for different request and there
are around 30 different request.

Now one solution can be that I create 30 messageSender and depending upon
the request use the corresponding message sender. But it doesn't feel right
to me.

Could anyone suggest some other way to do it in more proper way.?
Is there anyways we can change the username/password dynamically or the
messageSender.?


---
Regards,
atgroxx
Live the Moment.

Re: dynamically setting Registry based options messageSender

Posted by atg roxx <at...@gmail.com>.
Hi Claus,

I checked there too but did not found any helpful solution.

So I tried another thing.
What i did is that  I created 30 messageSender programatically and added
then @runtime to my application context.

I verified that all this messageSender are availiable in the context and I
am able to access them in sping-ws option messageSender usign #.

Now the problem is my call is getting fails to 3rd party and it says--
"org.springframework.ws.client.WebServiceTransportException: Authorization
Required [401]"


When debugged come to know that "Authorization: Basic " is missing.

---logs---
 2012-07-12 15:35:12,082 [Camel (DssCamelContext) thread #9 -
JmsConsumer[com.sbe.fees.request]  DEBUG
org.apache.commons.httpclient.HttpMethodDirector  - Authentication scope:
BASIC 'LOGIN'@zzzzzz.xxxxxxx.yyy:8009
 2012-07-12 15:35:12,082 [Camel (DssCamelContext) thread #9 -
JmsConsumer[com.sbe.fees.request]  DEBUG
org.apache.commons.httpclient.HttpMethodDirector  - Credentials required
 2012-07-12 15:35:12,082 [Camel (DssCamelContext) thread #9 -
JmsConsumer[com.sbe.fees.request]  DEBUG
org.apache.commons.httpclient.HttpMethodDirector  - Credentials provider
not available
------------------

But I am passing the same
org.apache.commons.httpclient.UsernamePasswordCredentials as I was passing
earlier in the context xml file as shown in the chain mail..


Any guess why it is happening. I am stuck on this for long time. any help
will be appreciated.




--Regards,
atgroxx

On Mon, Jul 9, 2012 at 10:08 AM, Claus Ibsen <cl...@gmail.com> wrote:

> On Mon, Jul 9, 2012 at 10:43 AM, atg roxx <at...@gmail.com> wrote:
> >  Hi All,
> >
> > Could anyone please give their thought over this problem.
> >
>
> Have you looked at spring ws documentation / forum etc. As it must be
> a similar problem there.
>
> Or maybe you can extend
> org.apache.commons.httpclient.UsernamePasswordCredentials and dynamic
> decide the username / password to return in the callbacks.
>
> I am not sure how easy that would be through, as I assume the
> callbacks is just getUsername / getPassword etc.
> But haven't looked myself
>
> > --Regards,
> > atgroxx
> > live thie moment!!
> >
> > On Fri, Jul 6, 2012 at 5:45 PM, atg roxx <at...@gmail.com> wrote:
> >
> >> Hi Team,
> >>
> >> I have some un usual requirement.
> >>
> >>
> >> I have to send spring-ws request to third party which require two level
> of
> >> authentication (server+application)
> >>
> >> I have overridden the CommonsHttpMessageSender for it as shown below.
> >> ----------------
> >> <bean id="messageSenderTest"
> >> class="com.estar.eif.sbe.helper.TestCommonsHttpMessageSender">
> >>         <constructor-arg index="0" ref="httpClient" />
> >>         <constructor-arg index="1" value="${request.header.username.gb
> }"
> >> />
> >>         <constructor-arg index="2" value="${request.header.password.gb
> }"
> >> />
> >>         <property name="credentials">
> >>             <bean
> >> class="org.apache.commons.httpclient.UsernamePasswordCredentials">
> >>                 <constructor-arg index="0" value="${username}" />
> >>                 <constructor-arg index="1" value="$password}" />
> >>             </bean>
> >>         </property>
> >>         <property name="connectionTimeout" value="${connectiontimeout}"
> />
> >>         <property name="readTimeout" value="${readtimeout}" />
> >>     </bean>
> >> ------------
> >>
> >> and I am using the Dynamic registry based option messageSender  like
> this
> >> --------------
> >>  "?messageFactory=#messageFactory&messageSender=#messageSenderTest
> >> -------------------
> >>
> >> And it is working perfectly fine :).
> >>
> >> Now the issue is, there is requirement change from our client that he
> want
> >> to us to send different username/password for different request and
> there
> >> are around 30 different request.
> >>
> >> Now one solution can be that I create 30 messageSender and depending
> upon
> >> the request use the corresponding message sender. But it doesn't feel
> right
> >> to me.
> >>
> >> Could anyone suggest some other way to do it in more proper way.?
> >> Is there anyways we can change the username/password dynamically or the
> >> messageSender.?
> >>
> >>
> >> ---
> >> Regards,
> >> atgroxx
> >> Live the Moment.
> >>
> >>
> >>
> >>
> >>
>
>
>
> --
> Claus Ibsen
> -----------------
> FuseSource
> Email: cibsen@fusesource.com
> Web: http://fusesource.com
> Twitter: davsclaus, fusenews
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
>

Re: dynamically setting Registry based options messageSender

Posted by Claus Ibsen <cl...@gmail.com>.
On Mon, Jul 9, 2012 at 10:43 AM, atg roxx <at...@gmail.com> wrote:
>  Hi All,
>
> Could anyone please give their thought over this problem.
>

Have you looked at spring ws documentation / forum etc. As it must be
a similar problem there.

Or maybe you can extend
org.apache.commons.httpclient.UsernamePasswordCredentials and dynamic
decide the username / password to return in the callbacks.

I am not sure how easy that would be through, as I assume the
callbacks is just getUsername / getPassword etc.
But haven't looked myself

> --Regards,
> atgroxx
> live thie moment!!
>
> On Fri, Jul 6, 2012 at 5:45 PM, atg roxx <at...@gmail.com> wrote:
>
>> Hi Team,
>>
>> I have some un usual requirement.
>>
>>
>> I have to send spring-ws request to third party which require two level of
>> authentication (server+application)
>>
>> I have overridden the CommonsHttpMessageSender for it as shown below.
>> ----------------
>> <bean id="messageSenderTest"
>> class="com.estar.eif.sbe.helper.TestCommonsHttpMessageSender">
>>         <constructor-arg index="0" ref="httpClient" />
>>         <constructor-arg index="1" value="${request.header.username.gb}"
>> />
>>         <constructor-arg index="2" value="${request.header.password.gb}"
>> />
>>         <property name="credentials">
>>             <bean
>> class="org.apache.commons.httpclient.UsernamePasswordCredentials">
>>                 <constructor-arg index="0" value="${username}" />
>>                 <constructor-arg index="1" value="$password}" />
>>             </bean>
>>         </property>
>>         <property name="connectionTimeout" value="${connectiontimeout}" />
>>         <property name="readTimeout" value="${readtimeout}" />
>>     </bean>
>> ------------
>>
>> and I am using the Dynamic registry based option messageSender  like this
>> --------------
>>  "?messageFactory=#messageFactory&messageSender=#messageSenderTest
>> -------------------
>>
>> And it is working perfectly fine :).
>>
>> Now the issue is, there is requirement change from our client that he want
>> to us to send different username/password for different request and there
>> are around 30 different request.
>>
>> Now one solution can be that I create 30 messageSender and depending upon
>> the request use the corresponding message sender. But it doesn't feel right
>> to me.
>>
>> Could anyone suggest some other way to do it in more proper way.?
>> Is there anyways we can change the username/password dynamically or the
>> messageSender.?
>>
>>
>> ---
>> Regards,
>> atgroxx
>> Live the Moment.
>>
>>
>>
>>
>>



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: dynamically setting Registry based options messageSender

Posted by atg roxx <at...@gmail.com>.
 Hi All,

Could anyone please give their thought over this problem.

--Regards,
atgroxx
live thie moment!!

On Fri, Jul 6, 2012 at 5:45 PM, atg roxx <at...@gmail.com> wrote:

> Hi Team,
>
> I have some un usual requirement.
>
>
> I have to send spring-ws request to third party which require two level of
> authentication (server+application)
>
> I have overridden the CommonsHttpMessageSender for it as shown below.
> ----------------
> <bean id="messageSenderTest"
> class="com.estar.eif.sbe.helper.TestCommonsHttpMessageSender">
>         <constructor-arg index="0" ref="httpClient" />
>         <constructor-arg index="1" value="${request.header.username.gb}"
> />
>         <constructor-arg index="2" value="${request.header.password.gb}"
> />
>         <property name="credentials">
>             <bean
> class="org.apache.commons.httpclient.UsernamePasswordCredentials">
>                 <constructor-arg index="0" value="${username}" />
>                 <constructor-arg index="1" value="$password}" />
>             </bean>
>         </property>
>         <property name="connectionTimeout" value="${connectiontimeout}" />
>         <property name="readTimeout" value="${readtimeout}" />
>     </bean>
> ------------
>
> and I am using the Dynamic registry based option messageSender  like this
> --------------
>  "?messageFactory=#messageFactory&messageSender=#messageSenderTest
> -------------------
>
> And it is working perfectly fine :).
>
> Now the issue is, there is requirement change from our client that he want
> to us to send different username/password for different request and there
> are around 30 different request.
>
> Now one solution can be that I create 30 messageSender and depending upon
> the request use the corresponding message sender. But it doesn't feel right
> to me.
>
> Could anyone suggest some other way to do it in more proper way.?
> Is there anyways we can change the username/password dynamically or the
> messageSender.?
>
>
> ---
> Regards,
> atgroxx
> Live the Moment.
>
>
>
>
>