четверг, 17 января 2013 г.

Axis 2 basic authentication on client

Some time ago I need to connect to web-service which use HTTP basic authentication. I had an Axis 2 client. So, here what I did:
HttpTransportProperties.Authenticator auth = new HttpTransportProperties.Authenticator();
auth.setPreemptiveAuthentication(true);
auth.setUsername(login);
auth.setPassword(password);
stub._getServiceClient().getOptions().setProperty(HTTPConstants.AUTHENTICATE,auth); 

Now you can connect to protected services.

Комментариев нет:

Отправить комментарий