Respected Camel Experts,

I am trying to access a web service that requires basic authentication. I am 
able to access using the CXF's JaxWsDynamicClientFactory. The code piece for 
auth looks like:

           JaxWsDynamicClientFactory dcf = 
JaxWsDynamicClientFactory.newInstance();
           Client client = dcf.createClient(ID_WSDL);
           
           HTTPConduit conduit= (HTTPConduit) client.getConduit();
           AuthorizationPolicy authorization =  conduit.getAuthorization();
           authorization.setUserName(USERNAME);
           authorization.setPassword(PWD);
           
           conduit.setAuthorization(authorization);


 However, when I try to use Camel's CXF component to access the same Web 
Service I get 401 Unauthorized error, since Camel is not sending the 
authentication information to the Web Service.

My route looks like:

    from("file://c:/test?fileName=request.txt&noop=true").routeId("myrouteId")
    .process(processor)
    .to(cxf)
    .to("log:{body}");

In my processor, I am setting the credentials as follows:

Map<String, Object> properties = new HashMap<String, Object>(); 

        AuthorizationPolicy authPolicy = new AuthorizationPolicy(); 
        authPolicy.setAuthorizationType(HttpAuthHeader.AUTH_TYPE_BASIC); 
        authPolicy.setUserName(USERNAME); 
        authPolicy.setPassword(PWD); 
        
        
properties.put("org.apache.cxf.configuration.security.AuthorizationPolicy", 
authPolicy);
        myEndpoint.setProperties(properties);

myEndpoint is CXFEndpoint, retrieved from Exchange. 

Am I missing something or something wrong here.

___________________ 
Thks & brgds 
P Manchanda
Mobile: +91-9911152374

Reply via email to