camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dmitriyC300 <dmitriyC...@gmail.com>
Subject Re: How to set username password in custom SOAP header from cxf endpoint and camel route to call external webservice
Date Tue, 24 May 2016 14:06:29 GMT
You could do that via cxf out interceptor.  You would need to create an
intercepter that will construct your soap header and register it with your
client(see camel cxf docs).  When your client sends a request, interceptor
will inject the soap header based on defined instructions.

Example:
public class YourSecurityInterceptor extends
AbstractPhaseInterceptor<Message> {
    public YourSecurityInterceptor() {
        super(Phase.PRE_PROTOCOL);
    }
public void handleMessage(SoapMessage mc) {
    List<Header> list = mc.getHeaders(); 
    ServiceAuthHeader auth = new ServiceAuthHeader();
    auth.setUserName("username");
    auth.setPassword("password");
    SoapHeader newHeader = new SoapHeader(new QName("namespace",
"name"),auth, new JAXBDataBinding(ServiceAuthHeader.class));
    newHeader.setDirection(Direction.DIRECTION_IN);
    list.add(newHeader);
}
}

Dmitriy



--
View this message in context: http://camel.465427.n5.nabble.com/How-to-set-username-password-in-custom-SOAP-header-from-cxf-endpoint-and-camel-route-to-call-externae-tp5782793p5783040.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message