You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by Nencho Lupanov <ne...@googlemail.com> on 2007/07/11 15:26:15 UTC

HttpBasicAuthentification scenarion

Hi all,
 i am trying to use the axis2 ServiceClient against
web service endpoint that has http basic authentification enabled.

I wonder - is there a way to get hold of the http-commons HttpClient
that is used underneath in order to set the Credentials?

Thanks,
Nencho

Re: HttpBasicAuthentification scenarion

Posted by Saminda Abeyruwan <sa...@gmail.com>.
If  you are using Axis2 1.2 upwards,

       HttpTransportProperties.Authenticator auth = new
HttpTransportProperties.Authenticator();
        auth.setUsername("foo");
        auth.setPassword("bar");
        // if you really need to speed up the basic auth; that is not
waiting till the server challenge,
        auth.setPreemptiveAuthentication(true);

        ...
        options.setProperty(HTTPConstants.AUTHENTICATE,auth);


else  http://wso2.org/library/161

Thus, with Axis2 1.2 prior, the configuration of transport authentication
has written is a way to encapsulate the underline auth challenge from the
server. User just have to provide the correct credentials to
HttpTransportProperties.Authenticator bean, rest is up to Axis2 transport
mechanism.

Thank you

Saminda

On 7/11/07, Nencho Lupanov <ne...@googlemail.com> wrote:
>
> Hi all,
>  i am trying to use the axis2 ServiceClient against
> web service endpoint that has http basic authentification enabled.
>
> I wonder - is there a way to get hold of the http-commons HttpClient
> that is used underneath in order to set the Credentials?
>
> Thanks,
> Nencho
>



-- 
Saminda Abeyruwan

Software Engineer
WSO2 Inc. - www.wso2.org

RE: HttpBasicAuthentification scenarion

Posted by "Ali, Haneef" <ha...@hp.com>.
Hi,

Stub.getOptions should help you.

// Sample code

HttpTransportProperties.Authenticator auth = new
HttpTransportProperties.Authenticator();

auth.setPreemptiveAuthentication(true);
auth.setAuthSchemes(authSchemes);

auth.setUsername("username"); 
auth.setPassword("password");

Options options = ((YourStub)._getServiceClient().getOptions(); 

options.setProperty(HTTPConstants.AUTHENTICATE, auth);

YourStub._getServiceClient().setOptions(options);


Haneef

________________________________

From: Nencho Lupanov [mailto:nencholupanov@googlemail.com] 
Sent: Wednesday, July 11, 2007 6:26 AM
To: axis-dev@ws.apache.org; axis-user@ws.apache.org
Subject: HttpBasicAuthentification scenarion


Hi all,
 i am trying to use the axis2 ServiceClient against 
web service endpoint that has http basic authentification enabled.
 
I wonder - is there a way to get hold of the http-commons HttpClient
that is used underneath in order to set the Credentials?
 
Thanks,
Nencho

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org