views:

1209

answers:

3

I tried to get it to work using the CXF User Guide, but I've had no luck.

I'm trying to call the web service using java code.

+1  A: 

Chris Dail wrote a blog entry about this: http://chrisdail.com/2008/03/31/apache-cxf-with-http-basic-authentication/

His blog entry shows you how to extend the SoapHeaderInterceptor to send a username and password

tobrien
That article is about how to secure a CXF web service using basic authentication, not how to connect to one. The interceptor implements basic authentication for a CXF Web Service. I need the client code to connect to a web service secured by basic authentication.
ScArcher2
+2  A: 

This is covered by the JAX-WS Specification. Basically, set the username/password as properties on the request context:

((BindingProvider)proxy).getRequestContext().put( BindingProvider.USERNAME_PROPERTY, "joe"); ((BindingProvider)proxy).getRequestContext().put( BindingProvider.PASSWORD_PROPERTY, "pswd");

The runtime puts them into the HTTP header.

Daniel Kulp
A: 

This should help http://cwiki.apache.org/CXF20DOC/developing-a-consumer.html