Hi,
You need write an interceptor yourself, let's the interceptor name is UsernameAndPasswordInterceptor, the phase should be quiet early, PRE_STREAM should be fine And if the RequestContext doesn't exist in the message just create one and set it in the message public class UsernameAndPasswordInterceptor extends AbstractPhaseInterceptor<Message> {

   public UsernameAndPasswordInterceptor() {
       super(Phase.PRE_STREAM);
   }

public void handleMessage(Message message) { //for your real code you need try to retrieve context and reqContext first, if they are null, they create and set it in
            Map<String, Object> context = new HashMap<String, Object>();
           Map<String, Object> reqContext = new HashMap<String, Object>();
reqContext.put(BindingProvider.USERNAME_PROPERTY, "yourusername"); reqContext.put(BindingProvider.PASSWORD_PROPERTY, "yourpswd"); }
           context.put("RequestContext", reqContext);
           message.put(Message.INVOCATION_CONTEXT, context);
}

And you also need add this interceptor to your cxf bc provider outInterceptor configure
              <cxfbc:outInterceptors>
<bean class="yourpackagename.UsernameAndPasswordInterceptor"/>
               </cxfbc:outInterceptors>

Freeman

Ola_S wrote:
Hi. Thank you for the reply. But I seem to be stuck. Could you please explain further. I am quite new to CXF and Servicemix.
What type of interceptor should I use, and in what phase?
I can“t get the INVOCATION_CONTEXT when i try your solution.
I also tried to get a hold of the httpConduit in the message, when fiddeling
with the SoapInterceptors, but failed miserably..

/O




Freeman Fang wrote:
Hi,
Yeah, you can do it by adding an interceptor for your cxf bc provider outgoing interceptor chain


Map<String, Object> reqCtx = org.apache.cxf.helpers.CastUtils.cast((Map<?, ?>)message.get(Message.INVOCATION_CONTEXT)); reqCtx = org.apache.cxf.helpers.CastUtils.cast((Map<?, ?>)reqCtx.get("RequestContext"));
      reqCtx.put(BindingProvider.USERNAME_PROPERTY, "yourusername");
      reqCtx.put(BindingProvider.PASSWORD_PROPERTY, "yourpswd");

Freeman
Ola_S wrote:
Hi.
I have a <cxfbc:provider> set up nicely. With user and password
configuration in busCfg  XML-file. This works like a charm, but now I
want
to dynamically set the user and password. Can I set this programatically in some way.
/O



Reply via email to