Finally I could able to find the solution to this problem. The following configuration and code snippets might be useful to others struggling with the same problem.
It looks like CXF had a bug in <jaxws:client/> not sending username and password values. applicationContext.xml: ----------------------- <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:soap="http://cxf.apache.org/bindings/soap" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://cxf.apache.org/bindings/soap http://cxf.apache.org/schemas/configuration/soap.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="location" value="WEB-INF/web_service.properties" /> </bean> <jaxws:client id="searchClient" serviceClass="com.client.service.SearchService" address="${webservice.host.url}/${soapservice.url}" /> <bean id="searchServiceBean" class="com.service.SearchBusinessServiceImpl"> <constructor-arg index="0" value="${username}"/> <constructor-arg index="1" value="${password}"/> <property name="searchService" ref="searchClient" /> </bean> </beans> com.service.SearchBusinessServiceImpl: -------------------------------------- public class SearchBusinessServiceImpl implements SearchBusinessService{ // Interface generated from WSDL private SearchService searchService; private String userName; private String password; public SearchBusinessServiceImpl(String userName, String password){ this.userName=userName; this.password=password; } public void setSearchService(SearchService searchService){ this.searchService=searchService; //Set basic authentication properties. BindingProvider provider = (BindingProvider) searchService; Map<String, Object> requestContext = provider.getRequestContext(); requestContext.put(BindingProvider.USERNAME_PROPERTY, this.userName); requestContext.put(BindingProvider.PASSWORD_PROPERTY, this.password); } } WEB-INF/web_service.properties: -------------------------------- webservice.host.url=http://localhost:8080 soapservice.url=appcontext/services/searchService username=uname password=pword -- View this message in context: http://www.nabble.com/Basic-authentication-with-Spring-configured-client-tp17500802p17521301.html Sent from the cxf-user mailing list archive at Nabble.com.
