camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Willem Jiang <willem.ji...@gmail.com>
Subject Re: Apache Camel v2.12 | CXF Component | Basic Authentication | Web Service
Date Wed, 22 Jan 2014 02:51:00 GMT
Hi,

If you set the cxfEndpoint property in a processor, it’s a setting of runtime.
As the CxfProducer is created during the camel context start the route, the cxfEndpoint’s
property is not updated.

My suggestion is you set the cxfEndpoint property in the route builder configure method instead
of a processor. 

--  
Willem Jiang

Red Hat, Inc.
Web: http://www.redhat.com
Blog: http://willemjiang.blogspot.com(http://willemjiang.blogspot.com/) (English)
http://jnn.iteye.com(http://jnn.javaeye.com/) (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem



On January 20, 2014 at 2:12:21 PM, P Manchanda (manchandap@yahoo.com) wrote:
>  
> 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 properties = new HashMap();  
>  
> 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
>  


Mime
View raw message