Unless the server sends authorization challenge request, httpclient is not going to send username/password. If your server can't send authorization challenge request then do preemptive authorization
Add the following line and then check in tcpmon authenticator .setPreemptiveAuthentication(true); Thanks, Haneef -----Original Message----- From: Shantanu Sen [mailto:[EMAIL PROTECTED] Sent: Friday, July 13, 2007 2:19 PM To: [email protected] Subject: Re: Axis2 - how to set ServiceClient with http basic auth I am using the following code but do not see any username/pw on the http request going out. Do I need to configure any transport related property? === ServiceClient axisClient = new ServiceClient(); HttpTransportProperties.Authenticator authenticator = (HttpTransportProperties.Authenticator)axisClient.getOptions().getProper ty(HTTPConstants.AUTHENTICATE); if (authenticator == null ) { authenticator = new HttpTransportProperties.Authenticator(); axisClient.getOptions().setProperty( HTTPConstants.AUTHENTICATE, authenticator); } // commenting the following out does'nt help either. authenticator.setRealm(HttpTransportProperties.Authenticator.BASIC); authenticator.setUsername("test_user"); authenticator.setPassword("test_password"); === I see that in AbstractHTTPSender, the following code on lines 398 - 402 (Axis2-1.2.1 src) are getting executed with the correct username/pw that I supplied: --- AbstractHTTSender--- ... else { /*Credentials only for Digest and Basic Authentication*/ creds = new UsernamePasswordCredentials(username, password); agent.getState().setCredentials(new AuthScope(AuthScope.ANY), creds); } --- But when I look at the request using tcpmon I do not see the username/pw. I see other http specific parameters such as cookie etc correctly set. Any ideas? Thanks, Shantanu ----- Original Message ---- From: Dimuthu <[EMAIL PROTECTED]> To: [email protected] Sent: Wednesday, July 11, 2007 8:47:51 PM Subject: Re: Axis2 - how to set ServiceClient with http basic auth Hi, HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator(); String username = "user"; String passwd = "pass"; auth.setUsername(username); auth.setPassword(passwd); // un-comment the below line if you are sending authentication details // without receiving 401 Authentication Required //auth.setPreemptiveAuthentication(true); options.setProperty(HTTPConstants.AUTHENTICATE,auth); Regards, Dimuthu On Wed, 2007-07-11 at 16:49 -0700, Shantanu Sen wrote: > The article at http://wso2.org/library/161 seems obsolete.There is no HttpTransportProperties.BasicAuthentication in the current Axis2-1.2 codebase. Can this article be updated? > > Is the basic and ntlm authentication unified so that we just need to use HttpTransportProperties.Authenticator? > > Is the property name to be used HttpConstatns.AUTHENTICATE? > > Thanks for any help. > Shantanu Sen > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
