A session can be created and bound to a service using an application username and password by using the Session service and the setSession method shown. The session will be restricted to the permissions of the account used to create it.
String sessionId =
new SessionService().getNovatusSessionServicePort()
.login(username, password);
public static void setSession(Object client, String sessionId) {
BindingProvider bp = (BindingProvider)client;
Map<String, List<String>> headers =
CastUtils.cast((Map<?,?>)bp.getRequestContext()
.get("javax.xml.ws.http.request.headers"));
if(headers == null) {
headers = new HashMap<String, List<String>>();
bp.getRequestContext()
.put("javax.xml.ws.http.request.headers", headers);
}
List<String> cookies =
Arrays.asList(new String[] {"NOVATUSSID="+sessionId});
headers.put("Cookie", cookies);
}
CODE
Then, to create and bind the session:
NovatusCompanyService companyService =
new CompanyService().getNovatusCompanyServicePort();
setSession(companyService, sessionId);