Hi
On 24/10/11 22:46, sdoca sdoca wrote:
Hi,

I am familiar with using Jersey to create RESTful webservice servers and 
clients, but due to class loading issues, I am trying to convert a Jersey 
client into CXF. I believe I want to use an HTTP-centric client but we don't 
use Spring.  We need to use basic HTTP authentication.  The user guide has this 
example:

     WebClient client = WebClient.create("http:books", "username", "password", 
"classpath:/config/https.xml");

The first parameter isn't a URI string. Is it a format used by Spring? Can this 
method only be used to create WebClients using Spring?

I've fixed the typo, thanks...
The 4th parameter has to be set to null if no Spring is involved - the reason it is there is that CXF HTTPConduit configuration is usually done in Spring:
https://cwiki.apache.org/confluence/display/CXF20DOC/JAX-RS+Client+API#JAX-RSClientAPI-ConfiguringanHTTPConduitfromSpring

Dan, can we configure HTTPConduit HTTPs from the code ?

The other way of doing authentication shown is to add a header string:

     String authorizationHeader = "Basic " +  
org.apache.cxf.common.util.Base64Utility.encode("user:password".getBytes());
     webClient.header("Authorization", authorizationHeader);

I am guessing that "user:password" should be substituted with the real values, 
but would appreciate confirmation.

Yes, those need to be replaced. I added a comment there.

Thanks, Sergey


Thanks!

(please note that I have also posted this on StackOverflow: 
http://stackoverflow.com/questions/7880707/cxf-restful-client-how-to-do-basic-http-authentication-without-spring)


Reply via email to