HttpTransportProperties.Authenticator authenticator = new HttpTransportProperties.Authenticator();
authenticator.setUsername(username);
authenticator.setPassword(password);
authenticator.setPreemptiveAuthentication(true);
ApplicationManagementServiceStub stub;
ConfigurationContext configurationContext = null;
try {
configurationContext = ConfigurationContextFactory.createDefaultConfigurationContext();
} catch (Exception e) {
String msg = "Backend error occurred. Please contact the service admins!";
throw new AxisFault(msg, e);
}
HashMap<String, TransportOutDescription> transportsOut = configurationContext
.getAxisConfiguration().getTransportsOut();
for (TransportOutDescription transportOutDescription : transportsOut.values()) {
transportOutDescription.getSender().init(configurationContext, transportOutDescription);
}
stub = new ApplicationManagementServiceStub(configurationContext, serverURL + "/services/ApplicationManagementService");
ServiceClient client = stub._getServiceClient();
Options option = client.getOptions();
option.setManageSession(true);
option.setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, authenticator);
option.setTimeOutInMilliSeconds(300000);
this.stub = stub;